Note that there are some explanatory texts on larger screens.

plurals
  1. POIB Actionsheet VS. programmed Action Sheet
    primarykey
    data
    text
    <p>Greetings all.</p> <p>I am attempting to implement Nate Weinders' "ShareKit" Framework. All went well, until the final step.</p> <p>I have a generic Action Button setup in Interface Builder with the name "shareBtn"</p> <p>In my .h I have:</p> <pre><code>-(IBAction)shareBtn; </code></pre> <p>In my .m I setup a generic (working) UIActionSheet:</p> <p>Up top I pull in the ShareKit Framework: #import "SHK.h"</p> <p>For my button I have this:</p> <pre><code> -(IBAction)shareBtn { UIActionSheet *actionsheet = [[UIActionSheet alloc] initWithTitle:@"Which do you prefer?" delegate:self cancelButtonTitle:@"Cancel" destructiveButtonTitle:@"Destuctive Button" otherButtonTitles:@"Button 1", @"Button 2", @"Button 3", nil ]; [actionsheet showInView:[self view]]; [actionsheet release]; } -(void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex { NSLog(@"button %i clicked", buttonIndex ); } </code></pre> <p>That works all fine and dandy. Now, according to the instruction on ShareKit's install page, I am to place this code to make the actionsheet hook into the sharekit Framework:</p> <pre><code>- (void)myButtonHandlerAction { // Create the item to share (in this example, a url) NSURL *url = [NSURL URLWithString:@"http://getsharekit.com"]; SHKItem *item = [SHKItem URL:url title:@"ShareKit is Awesome!"]; // Get the ShareKit action sheet SHKActionSheet *actionSheet = [SHKActionSheet actionSheetForItem:item]; // Display the action sheet [actionSheet showFromToolbar:navigationController.toolbar]; } </code></pre> <p>It seems fairly straight forward, and I played around with the syntax a bit (using self.toolbar, etc...) and I am just really struggling to grasp the concept and what I am missing. I read the iOS documentation on this, I referenced the few books I have, and did a lot of online searching. </p> <p>Just hoping can see an obvious error or help guide me a bit.</p> <p>Thank You.</p> <p>Here is what I tried and the errors:</p> <p>First Attempt</p> <pre><code> -(IBAction)shareBtn { // Create the item to share (in this example, a url) NSURL *url = [NSURL URLWithString:@"http://getsharekit.com"]; SHKItem *item = [SHKItem URL:url title:@"ShareKit is Awesome!"]; // Get the ShareKit action sheet SHKActionSheet *actionSheet = [SHKActionSheet actionSheetForItem:item]; // Display the action sheet [actionSheet showFromToolbar:navigationController.toolbar]; } </code></pre> <p>ERROR: 'navigationController undeclared'</p> <p>///////Second Attempt///////</p> <pre><code> -(IBAction)shareBtn { // Create the item to share (in this example, a url) NSURL *url = [NSURL URLWithString:@"http://getsharekit.com"]; SHKItem *item = [SHKItem URL:url title:@"ShareKit is Awesome!"]; // Get the ShareKit action sheet SHKActionSheet *actionSheet = [SHKActionSheet actionSheetForItem:item]; // Display the action sheet [actionSheet self.toolbar]; } </code></pre> <p>//////ERROR: 'Expected ']' before '.' token'//////////</p> <p>///////Third Attempt///////</p> <pre><code> -(IBAction)shareBtn { // Create the item to share (in this example, a url) NSURL *url = [NSURL URLWithString:@"http://getsharekit.com"]; SHKItem *item = [SHKItem URL:url title:@"ShareKit is Awesome!"]; // Get the ShareKit action sheet SHKActionSheet *actionSheet = [SHKActionSheet actionSheetForItem:item]; // Display the action sheet [actionSheet self.toolbar]; } </code></pre> <p>//////ERROR: 'Expected ']' before '.' token'//////////</p> <p>///////Fourth Attempt///////</p> <pre><code>-(IBAction)shareBtn { UIActionSheet *actionsheet = [[UIActionSheet alloc] init]; // Create the item to share (in this example, a url) NSURL *url = [NSURL URLWithString:@"http://getsharekit.com"]; SHKItem *item = [SHKItem URL:url title:@"ShareKit is Awesome!"]; // Get the ShareKit action sheet SHKActionSheet *actionSheet = [SHKActionSheet actionSheetForItem:item]; // Display the action sheet [actionsheet showInView:[self view]]; [actionsheet release]; } </code></pre> <p>//////ERROR: Unused variable 'actionSheet' ////////// //////App launches, but just as the action sheet goes to pop up it crashes///////</p> <p>FYI: ShareKit Install Page: [url=http://www.getsharekit.com/install/]ShareKit : Install[/url]</p> <p>ALSO: I'm in the middle of reading "Big Nerd Ranch Guides - iPhone Programming" right now.</p> <p>As a way too learn I try to apply some of the concepts I have been learning (some of which go a little beyond my current knowledge). I generally understand the specific errors, but am at lost of how to implement this action.</p> <p>What confuses me about this actionSheet is that it works perfectly fine with the first method which I have learned. I'm now trying to expand on that knowledge by pulling in the ShareKit Framework and making that execute. It seems really straight forward and I'm just really discouraged...</p> <p>Here is the ShareKit install (It says "In three easy lines of code") STEP 4: <a href="http://www.getsharekit.com/install/" rel="nofollow">http://www.getsharekit.com/install/</a></p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload