Wrox Programmer Forums
|
BOOK: Beginning iPad Application Development
This is the forum to discuss the Wrox book Beginning iPad Application Development by Wei-Meng Lee; ISBN: 9780470641651
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning iPad Application Development section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 11th, 2010, 12:30 PM
Registered User
 
Join Date: May 2010
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default Ch. 3 - usingViews Alert and ActionSheet

When I add the code snippets for alert, the app launches and works correctly in the iPad simulator. I do get a Warning that "Format not a literal and no format arguments."

I commented out the Alert snippets and added the actionSheet snippets. I still receive the Warning noted above. The app does not display the actionSheet window in the iPad simulator. The icon does appear. Clicking the icon in the sim looks like it is going to display the actionSheet but it doesn't.

I have deleted the icon and rebuilt on the simulator. Also compared code from the Chapter download UsingViews. It appears everything is as it should be.

Any idea why the app does display the actionSheet?

[update]
Thinking I may have missed something, I copied the UIActionSheet snippet, and the - (void)actionSheet: snippet to my project from the Chapter download. Verified the <UIActionSheetDelegate> was correct. Same result.

Last edited by johnoeffinger; May 11th, 2010 at 12:48 PM..
 
Old May 12th, 2010, 03:34 AM
Authorized User
 
Join Date: May 2010
Posts: 21
Thanks: 0
Thanked 6 Times in 4 Posts
Default UIActionSheet

Hi:
Thanks for the feedback.

To solve this error, move the code into an action, say btnClicked:

Code:
-(IBAction) btnClicked: (id) sender {
	UIActionSheet *action = [[UIActionSheet alloc]
		 initWithTitle:@"Title of Action Sheet"
		 delegate:self
		 cancelButtonTitle:@"OK"
		 destructiveButtonTitle:@"Delete Message"
		 otherButtonTitles:@"Option 1", @"Option 2", nil];
    [action showInView:self.view];
    [action release];	
}
Add a Button to the xib file and then connect its Touch Up Inside event to this action. It should work.

In any case, if your app crash during runtime, press Shift-Command-R to view the Debugger Console window and scroll to the bottom. It will tell you what caused the crash.

Hope it helps!

Wei-Meng Lee

Last edited by weimenglee; May 12th, 2010 at 03:37 AM..
 
Old June 2nd, 2010, 10:39 PM
Registered User
 
Join Date: May 2010
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to dsobol
Angry Could you elucidate?

In reference to your answer posted here, you state: "...then connect its Touch Up Inside event to this action." Could you elucidate this please?

I am working with an ebook, and though you do have an index in the ebook, the topics are not links, so they are basically useless unless I want to go through each page individually until I find this reference.... ::sigh::

I guess this is still new media....

Thanks for any and all assistance.

Steve
 
Old June 2nd, 2010, 10:49 PM
Registered User
 
Join Date: May 2010
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to dsobol
Default

Hmmm. I think I have found the reference for Touch Up Inside, but whern I try to cntrl click from the button to the File Owner, the link will not 'take'. I am unsure as to how to proceed.

TIA,

Steve
 
Old June 3rd, 2010, 06:09 PM
Registered User
 
Join Date: Jun 2010
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
Originally Posted by dsobol View Post
Hmmm. I think I have found the reference for Touch Up Inside, but whern I try to cntrl click from the button to the File Owner, the link will not 'take'. I am unsure as to how to proceed.

TIA,

Steve
Make sure you've included -(IBAction) etc.. in the header file of the view you are working with, because from what I understand, that's what IB will look at to see what actions it can link up to.
 
Old July 30th, 2010, 11:02 AM
Registered User
 
Join Date: Jun 2010
Posts: 9
Thanks: 2
Thanked 0 Times in 0 Posts
Default Same problem in the "Using the Action View" section

I haven't even gotten as far as the "Using the Action Sheet" section.

I get the "Warning that "Format not a literal and no format arguments" when trying to run the code in the "Using the Action View" section. I get it on the NSLog line of code in the following:

- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex {

NSLog([NSString stringWithFormat:@"%d", buttonIndex]);

}


I have copied the code directly from the the download files.

Added comment 1: I just re-downloaded the Chapter 3 code and attempted to compile and run the UsingView.xcodeproj file. It just runs and exits the app without displaying anything and with no debug messages. Using Xcode 3.2.2.

Added comment 2: Got it work. Definitely proved my Geezer status by being too concerned about the "Warning" and not realizing that the values were being shown in the Console window and that the app need to be re-run to get each value.

Is there a collective "Errata" file for this book? Or is it just in scattered postings here. Thanks.

Last edited by GeezerRoy; July 30th, 2010 at 05:00 PM.. Reason: Resolution of my code problems.
 
Old August 9th, 2010, 01:46 PM
Friend of Wrox
 
Join Date: Aug 2010
Posts: 298
Thanks: 1
Thanked 62 Times in 60 Posts
Default

Actually, it is best to eliminate warnings.
The correct way to do the NSLog is
Code:
NSLog(@"%d", buttonIndex);
This will eliminate the warnings.
stringWithFormat should not be used at all in the NSLog statement.
 
Old August 11th, 2010, 10:09 AM
Friend of Wrox
 
Join Date: Aug 2010
Posts: 298
Thanks: 1
Thanked 62 Times in 60 Posts
Default

The ActionSheet snippet can not be added to the -(void)viewDidLoad method, since the view it is trying to show itself in has not been attached to a window. It is attached as a subview in AppDelegate.m
Code:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {    
    
    // Override point for customization after app launch. 
    [window addSubview:viewController.view];
which is called after the -(void)viewDidLoad method

if you add the snippet after
Code:
[window addSubview:viewController.view]
it will display as expected

The console error that occurs when showing the alertView in the -(void)viewDidLoad
wait_fences: failed to receive reply: 10004003
is also caused by this.
The example would be better if the calls for the alertView and the calls for the ActionView occurred after the
Code:
 - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
has actually added the subView to the window.
Even though the examples as presented are not how you would use either of these views in practical terms, it is good to have code that doesn't give warnings or exceptions.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Search ch 13, ch 16 sporik BOOK: Beginning PHP 6, Apache, MySQL 6 Web Development ISBN: 9780470391143 0 October 27th, 2009 04:44 PM
alert darkhalf Javascript 3 November 18th, 2005 12:56 PM
Ch. 4 & Ch. 12 athena BOOK: Beginning PHP, Apache, MySQL Web Development ISBN: 978-0-7645-5744-6 0 July 23rd, 2004 10:54 AM
alert function mahulda ASP.NET 1.0 and 1.1 Basics 5 April 9th, 2004 11:05 PM
alert collie Javascript 2 December 29th, 2003 02:29 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.