How to resolve warning about does not implement the 'UIActionSheetDelegate' protocol - iphone

here is my .h code
#interface ROSettingViewController : UITableViewController
{
UISwitch *switchCtl;
UISwitch *switchCtl1;
NSArray *dataSourceArray;
}
#property (nonatomic, retain, readonly) UISwitch *switchCtl;
#property (nonatomic, retain, readonly) UISwitch *switchCtl1;
#property (nonatomic, retain) NSArray *dataSourceArray;
- (void)dialogOKCancelAction;
- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex;
#end
/Users/ragopor/Desktop/Power Spot beta 2/code/Classes/ROSettingViewController.m:321: warning: class 'ROSettingViewController' does not implement the 'UIActionSheetDelegate' protocol

Have you tried declaring your controller's adherence to the UIActionSheetDelegate protocol?
#interface ROSettingViewController : UITableViewController<UIActionSheetDelegate>

The chances are you're saying, on ROSettingViewController.m:321,
myActionSheet.delegate = self;
without having specified that your VC implements the UIActionSheetDelegate protocol

Related

How to make update method to be called in SpriteKit?

My ViewController.h:
#import UIKit;
#import SpriteKit;
#interface BGGameViewController : UIViewController
#property (nonatomic, weak) IBOutlet SKView *skView;
#property (nonatomic, weak) IBOutlet UIButton *finishGameButton;
#property (nonatomic, weak) IBOutlet UIButton *startNewGameButton;
- (IBAction)finishGame:(id)sender;
- (IBAction)startNewGame:(id)sender;
#end
But I don't know how to make update method to be called.
The method is this...
- (void)update:(NSTimeInterval)currentTime
{
...
}
This needs to be in your SKScene class though, not your viewcontroller.

How to subclass UITextView

How can I subclass UITextView in UIActionSheet to overwrite canBeforeFirstResponder to disable copy, select, and select all in UITextView.
#import <UIKit/UIKit.h>
#class English;
#protocol EnglishDelegate
- (void)dismissViewDidFinish:(UIViewController *)viewController;
#end
#interface English: UIViewController <UITextViewDelegate, UIScrollViewDelegate>
{
id<EnglishDelegate> delegate;
UITextView *textView;
UINavigationBar *navBar;
UINavigationController *navigationController;
}
#property (nonatomic, retain) UITextView *textView;
#property (nonatomic, assign) UINavigationBar *navBar;
#property (strong, nonatomic) UINavigationController *navigationController;
#property (nonatomic, assign) id<EnglishDelegate> delegate;
#property (nonatomic, retain) UIScrollView *scrollView;
-(void)dismissView:(id)sender;
#end
Anyone knows how to subclass it in h file.
Thanks for help.
You wouldn't subclass UITextView inside of another class; you would just plain subclass it in another file and override the canBecomeFirstResponder as so:
- (BOOL)canBecomeFirstResponder {
return NO;
}

Calling a function in viewcontroller from appdelegate

I want to call a function in a viewController from my appDelegate but with the following code, it doesn't get called. What am I doing wrong?
AppDelegate.h:
#import <UIKit/UIKit.h>
#import "DetailsToTransfer.h"
#class AccountDetailTransferViewController;
#interface AccountDetailTransferAppDelegate : NSObject <UIApplicationDelegate> {
DetailsToTransfer *objDetailsToTransfer;
}
#property (nonatomic, retain) DetailsToTransfer *objDetailsToTransfer;
#property (nonatomic, retain) IBOutlet UIWindow *window;
#property (nonatomic, retain) IBOutlet AccountDetailTransferViewController *viewController;
-(void)sendToTransferScreen:(NSArray *)detailsArray;
#end
AppDelegate.m:
....
-(void)sendToTransferScreen:(NSArray *)detailsArray {
[objDetailsToTransfer setLabels:detailsArray];
objDetailsToTransfer = [[DetailsToTransfer alloc]initWithNibName:#"DetailsToTransfer" bundle:nil];
[self.window addSubview:objDetailsToTransfer.view];
}
DetailsToTransfer.h:
#import <UIKit/UIKit.h>
#interface DetailsToTransfer : UIViewController {
NSArray *accountDetailsArray;
UILabel *nameLabel;
UILabel *accountLabel;
IBOutlet UIButton *btnTransfer;
IBOutlet UIButton *btnBack;
}
#property (nonatomic, retain) NSArray *accountDetailsArray;
#property (nonatomic, retain) IBOutlet UILabel *nameLabel;
#property (nonatomic, retain) IBOutlet UILabel *accountLabel;
-(IBAction)sendDetails;
-(IBAction)goBack;
-(void)setLabels:(NSArray *)array;
#end
DetailsToTransfer.m
....
-(void)setLabels:(NSArray *)array {
NSLog(#"Setting Labels");
self.nameLabel.text = [array objectAtIndex:0];
self.accountLabel.text = [array objectAtIndex:1];
}
....
I would like to add that all the properties have been synthesized and that I'm calling the method in the appDelegate properly (i checked using NSLogs)
In AppDelegate.m:
Looks as if you are calling a method on your object before the object has been created. Until you have alloc / init your object, there will be no labels to set text.
Try changing your method to this:
-(void)sendToTransferScreen:(NSArray *)detailsArray {
if (!objDetailsToTransfer) {
objDetailsToTransfer = [[DetailsToTransfer alloc]initWithNibName:#"DetailsToTransfer" bundle:nil];
[objDetailsToTransfer setLabels:detailsArray];
[self.window addSubview:objDetailsToTransfer.view];
}
}
The problem might be that you are trying to set the values on a object that hasn't been created yet. I also provided an if statement to prevent the object from being created multiple times.

IBOutlet is not recognized by Interface Builder when conditioning compiling in Interface declaration

If I add this conditioning compiling flag in my header file, which is a owner of a xib file, the xib file cannot read the IBOutlet and show as missing. And gives warnings.
In runtime it works fine. Did anybody experience the same problem?
/* MFMessageComposeViewControllerDelegate is available in iOS 4.0 and later. */
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 40000
#interface SendMoneyResponseVC : UITableViewController
<UINavigationControllerDelegate, MFMessageComposeViewControllerDelegate,
MFMailComposeViewControllerDelegate, UIActionSheetDelegate>
#else
#interface SendMoneyResponseVC : UITableViewController
<UINavigationControllerDelegate,
MFMailComposeViewControllerDelegate, UIActionSheetDelegate>
#endif
{
IBOutlet UITableView *sendMoneyTableVC;
IBOutlet UITableViewCell *refNumRemittanceCell;
IBOutlet UILabel *refNumLabel, *refNumValueLabel, *refNumInfoLabel;
IBOutlet UITableViewCell *refNumDomesticCell;
IBOutlet UILabel *domesticInfoLabel, *feeAndReferenceLabel;
IBOutlet UITableViewCell *shareRefNumCell;
IBOutlet UIButton *shareRefNumButton;
NSString *referenceNumber, *recipient, *currency, *mtoName;
float amount, fee;
int sendMoneyType;
UIAlertView *smsAlertView;
}
#property (nonatomic, retain) UITableView *sendMoneyTableVC;
#property (nonatomic, retain) UITableViewCell *refNumRemittanceCell;
#property (nonatomic, retain) UILabel *refNumLabel, *refNumValueLabel, *refNumInfoLabel;
#property (nonatomic, retain) UITableViewCell *refNumDomesticCell;
#property (nonatomic, retain) UILabel *domesticInfoLabel, *feeAndReferenceLabel;
#property (nonatomic, retain) UITableViewCell *shareRefNumCell;
#property (nonatomic, retain) UIButton *shareRefNumButton;
#property (nonatomic, retain) NSString *referenceNumber, *recipient, *currency, *mtoName;
#property float amount, fee;
#property int sendMoneyType;
- (IBAction) didPressShareButton;
#end
Have you tried restructuring your code in a way which is equivalent to the compiler, but is less likely to confuse Interface Builder? Something like this:
#interface SendMoneyResponseVC : UITableViewController
<UINavigationControllerDelegate,
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 40000
MFMessageComposeViewControllerDelegate,
#endif
MFMailComposeViewControllerDelegate,
UIActionSheetDelegate>
{ ... }
#end
This way there will be only one #interface/#end pair.
what is the reason for doing this? Unless you want to compile with an outdated SDK you should get rid of this.
Interface Builder doesn't preprocess your files, so it will see two #interfaces and one #end.
And interface builder can't parse something like this.

iPad/iPhone TableVIew help pushing a new view

So we have recently started developing applications for the iPad for our company. Unfortunately none of us here have ever done any iPhone/iPad development so we are just kind of learning on the fly and winging it. Basically our problem is happening when we try to push a view onto the screen when a table row is clicked. Neither of us can figure out why it's not doing it because the code looks 100% correct by anything we can tell. Here is what the didRowSelectedAtIndex: method looks like:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
// Navigation logic -- create and push a new view controller
if(pdvController == nil)
pdvController = [[PersonDetailViewController alloc] initWithNibName:#"PersonDetailView" bundle:[NSBundle mainBundle]];
Person *aPerson = [appDelegate.people objectAtIndex:indexPath.row];
pdvController.aPerson = aPerson;
[self.appDelegate.navigationController pushViewController:pdvController animated:YES];
}
and here is the header for the toolbarSearchViewController:
#import <UIKit/UIKit.h>
#import "RecentSearchesController.h"
#import "PersonDetailViewController.h"
#class ToolbarSearchAppDelegate, PersonDetailViewController;
#interface ToolbarSearchViewController : UIViewController <UISearchBarDelegate, UIPopoverControllerDelegate, RecentSearchesDelegate> {
ToolbarSearchAppDelegate *appDelegate;
UIToolbar *toolbar;
UISearchBar *searchBar;
UITableView *resultsTable;
PersonDetailViewController *pdvController;
RecentSearchesController *recentSearchesController;
UITableViewController *resultsTableController;
UIPopoverController *recentSearchesPopoverController;
}
#property (nonatomic, retain) IBOutlet UIToolbar *toolbar;
#property (nonatomic, retain) UISearchBar *searchBar;
#property (nonatomic, retain) IBOutlet UITableView *resultsTable;
#property (nonatomic, retain) ToolbarSearchAppDelegate *appDelegate;
#property (nonatomic, retain) PersonDetailViewController *pdvController;
#property (nonatomic, retain) UITableViewController *resultsTableController;
#property (nonatomic, retain) RecentSearchesController *recentSearchesController;
#property (nonatomic, retain) UIPopoverController *recentSearchesPopoverController;
#end
and the ToolbarSearchAppDelegate header:
#import <UIKit/UIKit.h>
#class ToolbarSearchViewController;
#interface ToolbarSearchAppDelegate : NSObject <UIApplicationDelegate> {
UIWindow *window;
ToolbarSearchViewController *viewController;
UINavigationController *navigationController;
NSMutableArray *people;
}
#property (nonatomic, retain) IBOutlet UIWindow *window;
#property (nonatomic, retain) IBOutlet ToolbarSearchViewController *viewController;
#property (nonatomic, retain) IBOutlet UINavigationController *navigationController;
#property (nonatomic, retain) NSMutableArray *people;
#end
and finally the personDetailController.h:
#import <UIKit/UIKit.h>
#class Person;
#interface PersonDetailViewController : UIViewController {
IBOutlet UITableView *tableView;
Person *aPerson;
}
#property (nonatomic, retain) Person *aPerson;
#property (nonatomic, retain) UITableView *tableView;
#end
We are getting pretty annoyed because neither of us can figure out why it's not loading and any help or insight you guys could provide would be amazing. I wasn't sure what you may need to see, so if you need anything more specific, let me know and I will post it. Thanks!
ps. I am not sure how the code tags are going to handle all of Obj-c's quirky syntax, so if you see syntax errors, just ignore them. Assume that it is syntactically correct and will compile and run...
This line looks a little odd:
[self.appDelegate.navigationController pushViewController:pdvController animated:YES];
try and make it
[self.navigationController pushViewController:pdvController animated:YES];
edit summing op, the problem is that you don't have a navigation controller, so you can't push a view controller like that. What you can do, is pushing a view controller modally, using
[self presentModalViewController:pdvController animated:YES];