Database Reference
In-Depth Information
Next we define the protocol for our CloseFriendDetailViewControllerDelegate . Add this line just
above the @interface line.
@protocol CloseFriendDetailViewControllerDelegate;
Next, we subscribe to four delegate protocols that we use in the implementation file. They
are UITextFieldDelegate , UINavigationControllerDelegate , UIActionSheetDelegate , and
UIImagePickerControllerDelegate . One thing to note here is that we aren't actually calling any
methods on the UINavigationControllerDelegate , but the UIImagePickerControllerDelegate does
require that we subscribe to it because it will be using methods on our behalf.
@interface CloseFriendDetailViewController : UIViewController <UITextFieldDelegate,
UINavigationControllerDelegate, UIActionSheetDelegate, UIImagePickerControllerDelegate>
Next we define some public properties inside the interface:
@property (strong, nonatomic) CloseFriend *closeFriend;
@property (assign) id<CloseFriendDetailViewControllerDelegate> delegate;
@property BOOL shouldStartEditing;
The last thing we need to do is define our actual delegate protocol. We add a delegate method
detailViewControllerDidClose: and we pass this controller as its parameter.
@protocol CloseFriendDetailViewControllerDelegate <NSObject>
-(void)detailViewControllerDidClose:(CloseFriendDetailViewController *)detailViewController;
@end
Imports and Private Interface Setup
Now we need to move over to our CloseFriendDetailViewController.m file. The first thing is to
add an import for the Quartz Core framework just above the CloseFriendDetailViewController.h
import. We do this to define a border around our image using quartz core. We will also import the
UIImage+Resize.h category to handle image resizing.
#import "UIImage+Resize.h"
#import <QuartzCore/QuartzCore.h>
We also need to create the properties that we use to interact with the Text Fields and Image View
that we created in the Storyboard file.
@interface CloseFriendDetailViewController ()
@property (weak) IBOutlet UITextField *txtFirstName;
@property (weak) IBOutlet UITextField *txtLastName;
@property (weak) IBOutlet UITextField *txtBirthday;
@property (weak) IBOutlet UIImageView *imgFriend;
@property (strong) NSDateFormatter *dateFormatter;
@end
 
Search WWH ::




Custom Search