开发者

control array in xcode

开发者 https://www.devze.com 2023-01-28 14:50 出处:网络
I am quite new to Xcode and still do not know a lot of things Xcode can do. I wanna ask if Xcode or Objective-C uses Control Arrays like VB6.

I am quite new to Xcode and still do not know a lot of things Xcode can do. I wanna ask if Xcode or Objective-C uses Control Arrays like VB6.

edit: posted question on seperate page. How to detect which label or image is selected when they are created dynam开发者_如何学运维ically


No, Xcode and Obj-C have nothing like control arrays, even though it would be pretty easy to replicate that behavior if you needed to. If you have a specific task you'd like to accomplish, post a question and we may be able to give you a more specific answer.


we have control array.... you can declare like UILabel *lblName[numberOfLabelsYouWant]

yes but I think what would be useful would be something like: IBOutlet UILabel* labLicense[20]; which generates a compile time error.


If you are asking how to detect which label or image is selected which are created at runtime, then:

  1. Assing tags to the labels/images while creating through code.

  2. Write a method which will be invoked when a particular image/label is pressed.

  3. Pass the id of the sender when invoking that method.

  4. When the invoked method is called,write the code for a particular tag of an image or label (you can use switch case here).

That's it.

0

精彩评论

暂无评论...
验证码 换一张
取 消