my app is close when press action (Sharekit)

Discussion in 'iOS Programming' started by ITCreative, Sep 2, 2011.

  1. ITCreative macrumors member

    Joined:
    Aug 4, 2011
    #1
    hi,

    I'm use ShareKit but when press button action my app is closed

    my app is build succeeded but when run and press action button is closed


    I do this :


    Adding ShareKit to my app

    and add this Frameworks :

    SystemConfiguration.framework
    Security.framework
    MessageUI.framework

    Base SDK and Deployment Targets : my xcode 3.2.6 and iSO 4.3


    Filling in API Keys


    Code:
    
    
    
    
    
    
    
    // PLEASE SEE INSTALL/CONFIG INSTRUCTIONS:
    // http://getsharekit.com/install
    
    
    
    
    
    
    // App Description
    // These values are used by any service that shows 'shared from XYZ'
    
    #define SHKMyAppName			[COLOR="Red"]@"my app"[/COLOR]
    #define SHKMyAppURL			[COLOR="red"]@"http://www.example.com"[/COLOR]
    
    
    
    /*
     API Keys
     --------
     This is the longest step to getting set up, it involves filling in API keys for the supported services.
     It should be pretty painless though and should hopefully take no more than a few minutes.
     
     Each key below as a link to a page where you can generate an api key.  Fill in the key for each service below.
     
     A note on services you don't need:
     If, for example, your app only shares URLs then you probably won't need image services like Flickr.
     In these cases it is safe to leave an API key blank.
     
     However, it is STRONGLY recommended that you do your best to support all services for the types of sharing you support.
     The core principle behind ShareKit is to leave the service choices up to the user.  Thus, you should not remove any services,
     leaving that decision up to the user.
     */
    
    
    
    // Delicious - https://developer.apps.yahoo.com/projects
    #define SHKDeliciousConsumerKey		[COLOR="red"]@"dj0yJmk9MGFlU0VOSkt3bnJRJmXXXXXXXXXXXXXXXXX"[/COLOR]
    #define SHKDeliciousSecretKey [COLOR="red"]@"70c961b8fb126977283cXXXXXXX"[/COLOR]
    
    // Facebook - http://www.facebook.com/developers
    // If SHKFacebookUseSessionProxy is enabled then SHKFacebookSecret is ignored and should be left blank
    
    #define SHKFacebookUseSessionProxy  NO 
    #define SHKFacebookKey				[COLOR="red"]@"237657XXXXXXXX"[/COLOR]
    #define SHKFacebookSecret			[COLOR="red"]@"82d4f2a69f2b05deXXXXX"[/COLOR]
    //#define SHKFacebookSessionProxyURL  @""
    
    // Read It Later - http://readitlaterlist.com/api/?shk
    #define SHKReadItLaterKey			[COLOR="red"]@"eWKA5b04d259dR9XXXXX"[/COLOR]
    
    // Twitter - http://dev.twitter.com/apps/new
    /*
     Important Twitter settings to get right:
     
     Differences between OAuth and xAuth
     --
     There are two types of authentication provided for Twitter, OAuth and xAuth.  OAuth is the default and will
     present a web view to log the user in.  xAuth presents a native entry form but requires Twitter to add xAuth to your app (you have to request it from them).
     If your app has been approved for xAuth, set SHKTwitterUseXAuth to 1.
     
     Callback URL (important to get right for OAuth users)
     --
     1. Open your application settings at http://dev.twitter.com/apps/
     2. 'Application Type' should be set to BROWSER (not client)
     3. 'Callback URL' should match whatever you enter in SHKTwitterCallbackUrl.  The callback url doesn't have to be an actual existing url.  The user will never get to it because ShareKit intercepts it before the user is redirected.  It just needs to match.
     */
    #define SHKTwitterConsumerKey		[COLOR="red"]@"mOYiXc6dZO6MXXXX"[/COLOR]
    #define SHKTwitterSecret			[COLOR="red"]@"e8wTtPSSR6blHS2AXXXXXX"[/COLOR]
    #define SHKTwitterCallbackUrl		[COLOR="red"]@"http://example.com/oauth"[/COLOR] // You need to set this if using OAuth, see note above (xAuth users can skip it)
    #define SHKTwitterUseXAuth			0 // To use xAuth, set to 1
    #define SHKTwitterUsername			@"" // Enter your app's twitter account if you'd like to ask the user to follow it when logging in. (Only for xAuth)
    
    // Bit.ly (for shortening URLs on Twitter) - http://bit.ly/account/register - after signup: http://bit.ly/a/your_api_key
    #define SHKBitLyLogin				[COLOR="red"]@"itcreative"[/COLOR]
    #define SHKBitLyKey					[COLOR="red"]@"R_97d95f20b8e1c63716XXXXXXXXXX"[/COLOR]
    
    // ShareMenu Ordering
    #define SHKShareMenuAlphabeticalOrder 1 // Setting this to 1 will show list in Alphabetical Order, setting to 0 will follow the order in SHKShares.plist
    
    // Append 'Shared With 'Signature to Email (and related forms)
    #define SHKSharedWithSignature		0
    
    
    
    /*
     UI Configuration : Basic
     ------
     These provide controls for basic UI settings.  For more advanced configuration see below.
     */
    
    // Toolbars
    #define SHKBarStyle					@"UIBarStyleDefault" // See: http://developer.apple.com/iphone/library/documentation/UIKit/Reference/UIKitDataTypesReference/Reference/reference.html#//apple_ref/c/econst/UIBarStyleDefault
    #define SHKBarTintColorRed			-1 // Value between 0-255, set all to -1 for default
    #define SHKBarTintColorGreen		-1 // Value between 0-255, set all to -1 for default
    #define SHKBarTintColorBlue			-1 // Value between 0-255, set all to -1 for default
    
    // Forms
    #define SHKFormFontColorRed			-1 // Value between 0-255, set all to -1 for default
    #define SHKFormFontColorGreen		-1 // Value between 0-255, set all to -1 for default
    #define SHKFormFontColorBlue		-1 // Value between 0-255, set all to -1 for default
    
    #define SHKFormBgColorRed			-1 // Value between 0-255, set all to -1 for default
    #define SHKFormBgColorGreen			-1 // Value between 0-255, set all to -1 for default
    #define SHKFormBgColorBlue			-1 // Value between 0-255, set all to -1 for default
    
    // iPad views
    #define SHKModalPresentationStyle	@"UIModalPresentationFormSheet" // See: http://developer.apple.com/iphone/library/documentation/UIKit/Reference/UIViewController_Class/Reference/Reference.html#//apple_ref/occ/instp/UIViewController/modalPresentationStyle
    #define SHKModalTransitionStyle		@"UIModalTransitionStyleCoverVertical" // See: http://developer.apple.com/iphone/library/documentation/UIKit/Reference/UIViewController_Class/Reference/Reference.html#//apple_ref/occ/instp/UIViewController/modalTransitionStyle
    
    // ShareMenu Ordering
    #define SHKShareMenuAlphabeticalOrder 1 // Setting this to 1 will show list in Alphabetical Order, setting to 0 will follow the order in SHKShares.plist
    
    // Append 'Shared With 'Signature to Email (and related forms)
    #define SHKSharedWithSignature		0
    
    /*
     UI Configuration : Advanced
     ------
     If you'd like to do more advanced customization of the ShareKit UI, like background images and more,
     check out http://getsharekit.com/customize
     */
    
    
    
    /*
     Debugging
     ------
     To show debug output in the console:
     1. uncomment section A below
     2. comment out section B below
     
     To hide debug output in the console:
     1. uncomment section B below
     2. comment out section A below
     */
    
    // A : show debug output
    //#define SHKDebugShowLogs			1
    //#define SHKLog( s, ... ) NSLog( @"<%p %@:(%d)> %@", self, [[NSString stringWithUTF8String:__FILE__] lastPathComponent], __LINE__, [NSString stringWithFormat:(s), ##__VA_ARGS__] )
    
    // B : hide debug output
    #define SHKDebugShowLogs			[COLOR="red"]0[/COLOR]
    #define SHKLog( s, ... ) 
    
    
    
    /*
     Advanced Configuration
     ------
     These settings can be left as is.  This only need to be changed for uber custom installs.
     */
    
    #define SHK_MAX_FAV_COUNT			3
    #define SHK_FAVS_PREFIX_KEY			@"SHK_FAVS_"
    #define SHK_AUTH_PREFIX				@"SHK_AUTH_"
    
    
    
    
    
    

    and Calling ShareKit.


    Code:
    #import "SHK.h"
    
    


    and Handling the Button Action


    Code:
    - (IBAction)myButtonHandlerAction
    {
    	NSString *text;
    	
    	if (displaycontaint.selectedRange.length > 0)
    		text = [displaycontaint.text substringWithRange:displaycontaint.selectedRange];
    	
    	else
    		text = displaycontaint.text;
    	
    	
    	SHKItem *item = [SHKItem text:text];
    	SHKActionSheet *actionSheet = [SHKActionSheet actionSheetForItem:item];
    	
    	[actionSheet showFromToolbar:self.navigationController.toolbar];
    	
    	//[SHK flushOfflineQueue];
    
    }
    
    
    

    Why this is happen :(
     
  2. Sykte macrumors regular

    Joined:
    Aug 26, 2010
    #2
    I'm guess without a crash message. Check the console are you receiving an unrecognized selector. If you are check the spelling of - (IBAction)myButtonHandlerAction, make sure it's wired up properly.


    Posting crash logs will help.
     
  3. ITCreative thread starter macrumors member

    Joined:
    Aug 4, 2011
  4. ITCreative thread starter macrumors member

    Joined:
    Aug 4, 2011
    #4
    thanks a lot

    i resolve it just change this line

    Code:
    [actionSheet showFromToolbar:self.view];
    
     
  5. DoingForSchool, Dec 27, 2011
    Last edited by a moderator: Dec 27, 2011

    DoingForSchool macrumors newbie

    Joined:
    Dec 27, 2011
    #5
    Help! Share Button do not work!

    Hi.

    I follow everything this link teach me.http://getsharekit.com/install/

    But why doesnt my button work?

    This is my code.

    Code:
    @interface EvoucherController : UIViewController 
    {
    	UIImageView *imageView;
    }
    
    @property (nonatomic, retain) UIImageView *imageView;
    
    @end
    
    
    #import "EvoucherController.h"
    #import "SHKItem.h"
    #import "SHKActionSheet.h"
    
    @implementation EvoucherController
    
    @synthesize imageView;
    
    - (void)dealloc
    {
    	[imageView release];
    	[super dealloc];
    }
    
    - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
    {
    	if (self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil])
    	{
    		self.toolbarItems = [NSArray arrayWithObjects:
    							 [[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil] autorelease],
    							 [[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAction target:self action:@selector(share)] autorelease],
    							 [[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil] autorelease],
    							 nil
    							 ];
    	}
    	
    	return self;
    }
    
    - (void)loadView 
    {
    	[super loadView];
    	
    	self.imageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"PageCtrl3.png"]];
    	
    	imageView.frame = CGRectMake(0,0,self.view.bounds.size.width,self.view.bounds.size.height);
    	
    	[self.view addSubview:imageView];
    	
    	[imageView release];
    }
    
    - (void)share
    {
    	SHKItem *item = [SHKItem image:imageView.image title:@"E-Voucher"];
    	SHKActionSheet *actionSheet = [SHKActionSheet actionSheetForItem:item];
    	
    	[actionSheet showFromToolbar:self.navigationController.toolbar];
    }
    
    @end
    But only the image show up and the toolbar did not. Can anyone help me?

    I am using xcode 4.2 and IOS 5.
     

Share This Page