Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 09-27-2010, 10:22 AM   #1 (permalink)
Registered Member
 
Join Date: Sep 2010
Posts: 85
prchn4christ is on a distinguished road
Default navbar button

I am trying to create a share button for a Nav Bar. I've been able to create the button, and it is appearing on the pages I want it to. I've also set up a UIAlertView to bring up 3 buttons - to share with facebook, twitter, and email.

However, a few things I can't figure out:

How do I link the 'Share' button to the UIAlertView. I tried inserting the UIAlertView rename into the action selector, but it wasn't working. The UIAlertView is in the same .m file, does it need to go elsewhere?


UIBarButtonItem *shareButton = [[UIBarButtonItem alloc] initWithTitle:@"Share Article" style:UIBarButtonSystemItemDone target:nil action:@selector(????)];
self.navigationItem.rightBarButtonItem = shareButton;
[shareButton release];


Second, the UIAlertView pops a window in the middle of the screen. I'd rather it scroll up from the bottom. How can I change the type of UIAlertView?




Finally, I'd appreciate any code as to how to make the three buttons (facebook, email, twitter) take the text from the page and post it, or send it out. Thanks!
prchn4christ is offline   Reply With Quote
Old 09-27-2010, 11:07 AM   #2 (permalink)
Registered Member
 
Join Date: Jul 2009
Posts: 50
o2fill is on a distinguished road
Default

For your first question, set the target to "self" and the selector to the name of the method you wish to call that will display the alertView - maybe something like "showShareAlert" which could be coded as ...

Code:
-(void)showShareAlert {
     UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Title" message:@"AThe message."  delegate:self cancelButtonTitle:@"button 1" otherButtonTitles: @"Facebook", @"Twitter", @"Email", nil];
		[alert show];
		[alert release];
}
Then you'll need a method to handle the response, something like:

Code:
- (void)alertView:(UIAlertView *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex {
  
  // the user clicked one of the buttons
  switch (buttonIndex){
        case 0:
         // handle a cancel event
         break;

        case 1:
        //handle a facebook share
        break;

        case 2:
        //handle twitter
        break;

        case 3:
        //handle email
        break;

        default:
        //do whatever
        break;
   }
 

}
be sure that your header file includes the AlertViewDelegate protocol declaration like this:

Code:
@interface aViewController : UIViewController <UIAlertViewDelegate>
You're on your own on the specifics of Facebook and Twitter. Sorry.
o2fill is offline   Reply With Quote
Old 09-27-2010, 11:14 AM   #3 (permalink)
Registered Member
 
Join Date: Jul 2009
Posts: 50
o2fill is on a distinguished road
Default Action Sheet

Sorry, I forgot to answer the slide up from the bottom question. The answer is to use an ActionSheet instead of an AlertView. Here's a good tutorial on Action sheets:

iPhone SDK Tutorial: How to Make an Action Sheet | Iphone Development Exchange
o2fill is offline   Reply With Quote
Old 09-27-2010, 01:19 PM   #4 (permalink)
Registered Member
 
Join Date: Sep 2010
Posts: 85
prchn4christ is on a distinguished road
Default perfect

O2fill ...


THANKS! Instead of setting it up as a UIAlertView, I used the video tutorial and set it up as a UIActionSheet. I had been setting it up as a IBAction, which is clearly where I was going wrong, and hadn't been able to link it to the UIBarButtonItem.

The UIActionSheet must be what makes it perform by coming up from the bottom as opposed to just popping up. So, that button is now working ... again, thanks!

Now, anyone have code for facebook, twitter or email sharing? :-)
prchn4christ is offline   Reply With Quote
Reply

Bookmarks

Tags
button, email, facebook, twitter, uialertview

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 351
6 members and 345 guests
headkaze, mistergreen2011, nobstudio, Objective Zero, revg, v1n2e7t
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,655
Threads: 94,116
Posts: 402,889
Top Poster: BrianSlick (7,990)
Welcome to our newest member, pungs
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 11:08 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0