Please do not post the same thing multiple times. The board software automatically flags certain posts as needing moderator attention. This happens the most often for new users. I'm pretty sure this is made clear at the time you attempt to post. Posting the same thing over and over again just makes that many more posts the moderators have to weed through later. This makes us sad. Don't make us sad. If your post/thread doesn't appear, just wait a while. Don't post it again. If it hasn't shown up by the next day, then you can try again. I normally go through posts in the mornings, and try to check a few times throughout the day, but I'm not here 24/7. There will typically be a significant delay before posts are approved. Just be patient.
I have given my self a crash course in iphone dev over the last 2-3 weeks, so im still finding my feet with objective-c.
I have a small project where i read in data from an XML off the internet. One of the parameters is an email address. What i would like to do is send the value of this tag to the UIButton selector, so from there i can open the mail client on the phone and send an email.
Each UIButton is programatically in a for loop because there are going to be multiple instances of the . I would like to send a NSString, the contents of the tag, as an argument to the @selector. I am aware of comparing the title and im also aware of the tag but i dont think i can use these as the title of the buttons will always be "email" and the tag is an integer.
I would be grateful if someone could point me in the right direction.
Thanks for your reply. Im not quite sure how to subclass UIButton, but i can certainly implement the array approach. In your opinion which would be the best approach?
Your ButtonWithEmail now is normall UIButton controll with additional NSString property, where you can store your content. Don't forget to release it in dealloc.
The problem is you are creating button using factory method buttonWithType. In your subclass you don't override it and it is invoked on super: UIButton. UIButton buttonWithType returns new UIButton object but NOT your extended subclass object. All works when you are creating button by:
In my case in past it was ok, cause i had custom buttons with image in my project. Problem is that after init you can't set button style because this property is read-only in UIButton.
I think in this case easier way will be my first idea with array ;)
Ahhh ok that makes sense. However, i have started down this road so im going to try and follow it through :)
I have amended my code and the app does not crash, but there is no button being create (visibly at least). Please could you explain how i would go about creating the custom buttons so it get displayed on my app?
Replies
You can also try subclassing of UIButton adding email NSString property, then in action method you can easily obtain this.
[IMG]http://a1.phobos.apple.com/us/r1000/059/Purple/fb/c2/40/mzi.powocifh.75x75-65.jpg[/IMG]
Get the most Recent Photos of your friends!
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like AwesomeThanks for your reply. Im not quite sure how to subclass UIButton, but i can certainly implement the array approach. In your opinion which would be the best approach?
Regards,
-Ben
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like AwesomeYour ButtonWithEmail now is normall UIButton controll with additional NSString property, where you can store your content. Don't forget to release it in dealloc.
[IMG]http://a1.phobos.apple.com/us/r1000/059/Purple/fb/c2/40/mzi.powocifh.75x75-65.jpg[/IMG]
Get the most Recent Photos of your friends!
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like AwesomeButton.h
Button.m
i import "Button.h" in the main header
main Implementation
Button Method
I receive an SIGABRT error every time i compile.
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like AwesomeError Message
I have read some threads on various forums and the general consensus is that UIButton can not be subclassed, is this true?
Regards,
-Ben
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like Awesomebut you will lose RoundedRectStyle.
In my case in past it was ok, cause i had custom buttons with image in my project. Problem is that after init you can't set button style because this property is read-only in UIButton.
I think in this case easier way will be my first idea with array ;)
[IMG]http://a1.phobos.apple.com/us/r1000/059/Purple/fb/c2/40/mzi.powocifh.75x75-65.jpg[/IMG]
Get the most Recent Photos of your friends!
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like AwesomeI have amended my code and the app does not crash, but there is no button being create (visibly at least). Please could you explain how i would go about creating the custom buttons so it get displayed on my app?
Regards,
-Ben
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Disagree Dislike Like Awesome