I have some generic generated ImageViews in a scrollView each of these images have 2 gestureRecognizer for single/double tapping on the ImageView. Now my problem is how to identify whether the ImageView was tapped for first or second time. In some scenarios it's easy to use the tag of an ImageView, but I have two different gestureRecognizer on each ImageView and every gestureRecognizer uses a different identification method based on the tag number, to identify the image.
Here I generate the ImageViews dynamically:
-(void) initLevels{
_level = [Level alloc];
_unit = [Unit alloc];
self->_units = [[NSMutableArray alloc] init];
_keys = [[NSMutableArray alloc] init]
;
int x = 0;
int y = 0;
int i = 0;
for (NSObject *object in self->_levels) {
if ([object isKindOfClass:_level.class] && i != 0) {
x = x + MARGIN_RIGHT + OBJECT_WIDTH;
y = 0;
}
else if ([object isKindOfClass:_unit.class]){
_unit = (Unit *) object;
[self->_units addObject:_unit.description];
UIImageView *imageView = [[UIImageView alloc] initWithImage:self.box];
[imageView setFrame:CGRectMake(x, y, OBJECT_WIDTH, BOX_HEIGHT)];
imageView.highlighted = TRUE;
imageView.tag = i; //when this is not outlined the gestureRecognizer for singleTapping works but on the other hand the double tap gestureRecognizer just works for the first object, because its' tag is set on 0.
UITapGestureRecognizer *doubleTapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:#selector(unitDoubleTapped:)];
doubleTapGesture.numberOfTapsRequired = 2;
imageView.userInteractionEnabled = YES;
[imageView addGestureRecognizer:doubleTapGesture];
UITapGestureRecognizer *singleTapGesture =
[[UITapGestureRecognizer alloc] initWithTarget:self action:#selector(unitSingleTapped:)];
singleTapGesture.numberOfTapsRequired = 1;
//telling the singleTapGesture to fail the doubleTapGesture, so both doesn't fire at the same time
[singleTapGesture requireGestureRecognizerToFail:doubleTapGesture];
[imageView addGestureRecognizer:singleTapGesture];
UILabel *labelHeadline = [[UILabel alloc] initWithFrame:CGRectMake(5, 2, 220, 20)];
[labelHeadline setFont:[UIFont boldSystemFontOfSize:12]];
labelHeadline.textAlignment = NSTextAlignmentCenter;
[labelHeadline setBackgroundColor:[[UIColor whiteColor] colorWithAlphaComponent:0]];
labelHeadline.text = _unit.headline;
labelHeadline.numberOfLines = 0;
[labelHeadline sizeToFit];
UILabel *labelPrice = [LabelUtils deepLabelCopy:labelHeadline withText:[NSString stringWithFormat:#"Price: %#",_unit.price] withFrame:NO];
[labelPrice setTextAlignment:NSTextAlignmentLeft];
[labelPrice setFrame:CGRectMake(labelHeadline.frame.origin.x, labelHeadline.frame.origin.y + labelHeadline.frame.size.height + 2, 220, 20)];
UILabel *labelCRM = [LabelUtils deepLabelCopy:labelHeadline withText:[NSString stringWithFormat:#"CRM: %#", _unit.crm] withFrame:NO];
[labelCRM setTextAlignment:NSTextAlignmentLeft];
[labelCRM setFrame:CGRectMake(labelPrice.frame.origin.x, labelPrice.frame.origin.y + labelPrice.frame.size.height + 2, 220, 20)];
UITextView *textView= [[UITextView alloc] initWithFrame:CGRectMake(0,0, OBJECT_WIDTH, OBJECT_HEIGHT)];
[textView addSubview:labelHeadline];
[textView addSubview:labelPrice];
[textView addSubview:labelCRM];
[textView setUserInteractionEnabled:NO];
[textView setEditable:NO];
textView.backgroundColor = [[UIColor whiteColor]colorWithAlphaComponent:0];
textView.textAlignment = NSTextAlignmentLeft;
[imageView addSubview:textView];
[_scrollView addSubview:imageView];
y = y + MARGIN_BOTTOM + BOX_HEIGHT;
}
[self->_keys addObject:[NSNumber numberWithInt:i]];
i++;
}//remove the last keys which are to much in the _keys array
while ([self->_keys count] > ([self->_units count])) {
[_keys removeLastObject];
i--;
}
self.contents = [NSDictionary dictionaryWithObjects:self->_units forKeys:_keys];
}
Here is the code for the two gesture Recognizer
-(void)unitDoubleTapped:(UIGestureRecognizer *)gestureRecognizer{
self->_unitViewForDoubleTapIdentification = (UIImageView *)gestureRecognizer.view;
switch (self->_unitViewForDoubleTapIdentification.tag) {
case 0:
[_unitViewForDoubleTapIdentification setHighlightedImage:self.transparentBox];
self->_unitViewForDoubleTapIdentification.tag = 1;
break;
case 1:
[_unitViewForDoubleTapIdentification setHighlightedImage:self.box];
self->_unitViewForDoubleTapIdentification.tag = 0;
break;
default:
break;
}
}
and Here the singleTap
- (IBAction)unitSingleTapped:(id)sender {
[self dismissAllPopTipViews];
UIGestureRecognizer *gestureRecognizer = [UIGestureRecognizer alloc];
gestureRecognizer = (UIGestureRecognizer *)sender;
UIImageView *imageView = [[UIImageView alloc] init];
imageView = (UIImageView *)gestureRecognizer.view;
if (sender == _currentPopTipViewTarget) {
// Dismiss the popTipView and that is all
self.currentPopTipViewTarget = nil;
}
NSString *contentMessage = nil;
UIImageView *contentView = nil;
NSNumber *key = [NSNumber numberWithInt:imageView.tag];
id content = [self.contents objectForKey:key];
if ([content isKindOfClass:[NSString class]]) {
contentMessage = content;
}
else {
contentMessage = #"A large amount ot text in this bubble\najshdjashdkgsadfhadshgfhadsgfkasgfdasfdhasdkfgaodslfgkashjdfg\nsjfkasdfgkahdjsfghajdsfgjakdsfgjjakdsfjgjhaskdfjadsfgjdsfahsdafhjajdskfhadshfadsjfhadsjlfkaldsfhfldsa\ndsfgahdsfgajskdfgkafd";
}
NSArray *colorScheme = [_colorSchemes objectAtIndex:foo4random()*[_colorSchemes count]];
UIColor *backgroundColor = [colorScheme objectAtIndex:0];
UIColor *textColor = [colorScheme objectAtIndex:1];
CMPopTipView *popTipView;
if (contentView) {
popTipView = [[CMPopTipView alloc] initWithCustomView:contentView];
}
else {
popTipView = [[CMPopTipView alloc] initWithMessage:contentMessage];
}
[popTipView presentPointingAtView:imageView inView:self.view animated:YES];
popTipView.delegate = self;
popTipView.disableTapToDismiss = YES;
popTipView.preferredPointDirection = PointDirectionUp;
if (backgroundColor && ![backgroundColor isEqual:[NSNull null]]) {
popTipView.backgroundColor = backgroundColor;
}
if (textColor && ![textColor isEqual:[NSNull null]]) {
popTipView.textColor = textColor;
}
popTipView.animation = arc4random() % 2;
popTipView.has3DStyle = (BOOL)(arc4random() % 2);
popTipView.dismissTapAnywhere = YES;
[popTipView autoDismissAnimated:YES atTimeInterval:3.0];
[_visiblePopTipViews addObject:popTipView];
self.currentPopTipViewTarget = sender;
}
Hope you can help me, thanks in advance.
that's a lot of code to go through.. but I add more identifiers to UIViews (ie other than the tag identifier) by using obj-c runtime associative references..
So this is a category I attach to my UIView:
#import "UIView+Addons.h"
#import <objc/runtime.h>
#define kAnimationDuration 0.25f
#implementation UIView (Addons)
static char infoKey;
static char secondaryInfoKey;
-(id)info {
return objc_getAssociatedObject(self, &infoKey);
}
-(void)setInfo:(id)info {
objc_setAssociatedObject(self, &infoKey, info, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
}
-(id)secondaryInfo {
return objc_getAssociatedObject(self, &secondaryInfoKey);
}
-(void)setSecondaryInfo:(id)info {
objc_setAssociatedObject(self, &secondaryInfoKey, info, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
}
#end
here is an example of my own code where I use the above to address a problem similar to the one you're facing:
if (![[view info] boolValue]) { // not selected?
self.moveToFolderNumber = [view secondaryInfo];
[view setInfo:#YES];
}
Related
In one of the projects I'm working on, I have a UIScrollView that has a lot of buttons and labels that resemble movie theater seats that the user can tap to select seats for them to buy. Is it possible to zoom the UIScrollView? I have already declared the UIScrollViewDelegate, set the delegate to self, set the minimum and maximum zoom scale but I'm having issues with the viewForZoomingInScrollView and scrollViewDidEndZooming methods. I tried to return my scrollview on the viewForZoomingInScrollView method but it crashes.
Here's some of the code:
- (void) renderSeatMapOnScreen
{
int x_offset_row = 10;
int y_offset_row = 25;
int x_offset_col = 30;
int y_offset_col = 0;
int scrollview_w = 0;
int scrollview_h = 0;
NSString *row_name = #"";
int tag_index = 0;
NSMutableArray *seat_map_table = [seat_map_xml seats_map];
NSString *seat_available_str = [seat_avail_xml seat_available];
HideNetworkActivityIndicator();
NSLog(#"Seats available = %#", seat_available_str);
NSArray *seats_avail = [seat_available_str componentsSeparatedByString:#";"];
int ROW_COL_OFFSET = 25;
for (int row = 0; row < [seat_map_table count]; row++)
{
UILabel * rowlabel = [[UILabel alloc] init];
rowlabel.frame = CGRectMake(x_offset_row , y_offset_row, 22, 22);
SeatMapDeclaration *rowmap = [seat_map_table objectAtIndex:row];
rowlabel.text = rowmap.rows;
[scrollview addSubview:rowlabel];
row_name = [NSString stringWithFormat:#"%#", rowmap.rows];
NSArray *seat = [rowmap.rowmap componentsSeparatedByString:#";"];
NSLog(#"row[%i] = %#", row, rowmap.rowmap);
if (row == 0)
{
scrollview_w = [seat count] * ROW_COL_OFFSET + y_offset_row;
total_column = [seat count];
total_row = [seat_map_table count];
}
x_offset_col = 30 ;
y_offset_col = y_offset_row ;
for (int column = 0; column < [seat count]; column++)
{
if (([[seat objectAtIndex:column] rangeOfString:#"a("].location != NSNotFound)
|| ([[seat objectAtIndex:column] isEqualToString:#""]))
{
CGRect myImageRect = CGRectMake(x_offset_col, y_offset_col, 22, 22);
UIImageView *imageView = [[UIImageView alloc] initWithFrame:myImageRect];
[imageView setImage:[UIImage imageNamed:#"noseat.png"]];
[scrollview addSubview:imageView];
}
else if ([[seat objectAtIndex:column] rangeOfString:#"b("].location != NSNotFound)
{
CGRect myImageRect = CGRectMake(x_offset_col, y_offset_col, 22, 22);
UIImageView *imageView = [[UIImageView alloc] initWithFrame:myImageRect];
imageView.image = [UIImage imageNamed:#"noseat.png"];
[scrollview addSubview:imageView];
}
else
{
NSString *status = [NSString stringWithFormat:#"%#%#", row_name, [seat objectAtIndex:column]];
BOOL matchedFound = NO;
for (int i = 0; i < [seats_avail count]; i++)
{
if ([[seats_avail objectAtIndex:i] isEqualToString:status])
{
matchedFound = YES ;
break ;
}
}
if (matchedFound == YES)
{
UIButton * seat_btn = [UIButton buttonWithType:UIButtonTypeCustom];
[seat_btn setBackgroundImage:[UIImage imageNamed:#"seatavailable.png"] forState:UIControlStateNormal];
[seat_btn setBackgroundImage:[UIImage imageNamed:#"seatactive.png"] forState:UIControlStateSelected];
seat_btn.frame = CGRectMake(x_offset_col, y_offset_col, 22, 22);
tag_index = [[seat objectAtIndex:column] intValue];
[seat_btn setTitle:[seat objectAtIndex:column] forState:UIControlStateNormal];
seat_btn.titleLabel.font = [UIFont fontWithName:#"Helvetica" size:12.0];
seat_btn.tag = tag_index + row * 100;
[seat_btn addTarget:self
action:#selector(checkboxButton:)
forControlEvents:UIControlEventTouchUpInside];
[scrollview addSubview:seat_btn];
}
else
{
CGRect myImageRect = CGRectMake(x_offset_col, y_offset_col, 22, 22);
UIImageView *imageView = [[UIImageView alloc] initWithFrame:myImageRect];
imageView.image = [UIImage imageNamed:#"seat_not_available.png"];
[scrollview addSubview:imageView];
}
}
x_offset_col += ROW_COL_OFFSET ;
NSString *data = #"";
[seatControl addObject:data];
}
y_offset_row += ROW_COL_OFFSET;
}
UILabel *screenlabel = [[UILabel alloc] init];
screenlabel.frame = CGRectMake((scrollview_w-300)/2, 3, 300, 15);
screenlabel.text = #"Screen";
screenlabel.backgroundColor = [UIColor blackColor];
screenlabel.textColor = [UIColor whiteColor] ;
screenlabel.font = [UIFont fontWithName:#"Helvetica" size:10.0];
screenlabel.textAlignment = UITextAlignmentCenter;
[scrollview addSubview:screenlabel];
scrollview_h = y_offset_row + ROW_COL_OFFSET;
// Adjust scroll view
[scrollview setContentSize:CGSizeMake(scrollview_w, scrollview_h )];
}
- (UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView
{
NSLog(#"1");
return scrollview;
}
- (void)scrollViewDidEndZooming:(UIScrollView *)scrollView withView:(UIView *)view atScale:(float)scale
{
NSLog(#"2");
}
In:
- (UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView
{
NSLog(#"1");
return scrollview;
}
you are not supposed to return the UIScrollView itself, rather its subview that you would like to scroll/zoom.
If you have many subviews, I would suggest creating a container view for all of them that you return from viewForZoomingInScrollView; instead of adding your seats to the scrollview itself you would then add them to the container view.
If you want to zoom to a certain seat in the UIScrollView, you should use zoomToRect: animated:. You can specify a certain rectangle (i.e. the seat) to which you would like to zoom in on.
Zooming only works when you implement the viewForZoomingInScrollView: delegate callback.
UIImageView *tempImage = [[UIImageView alloc]initWithImage:[UIImage imageWithData:data]];
self.imageView = tempImage;
scrollView.contentSize = CGSizeMake(imageView.frame.size.width , imageView.frame.size.height);
scrollView.maximumZoomScale = 1;
scrollView.minimumZoomScale = .37;
scrollView.clipsToBounds = YES;
scrollView.delegate = self;
[scrollView addSubview:imageView];
scrollView.zoomScale = .37;
-(UIView *) viewForZoomingInScrollView:(UIScrollView *)inScroll {
return imageView;
}
I am creating two label programmatically using this code..
-(void)addLabel:(id)sender
{
ExampleAppDataObject* theDataObject = [self theAppDataObject];
theDataObject.count = theDataObject.count+1;
NSLog(#"count is :%i",theDataObject.count);
if (theDataObject.count == 2) {
addLabel.enabled = NO;
}
if (theDataObject.count == 1) {
CGRect imageFrame = CGRectMake(10, 10, 150, 80);
labelResizableView = [[UserResizableView alloc] initWithFrame:imageFrame];
blabel = [[UILabel alloc] initWithFrame:CGRectMake(10, 35, 100, 100)];
blabel.text = #"Write here";
//alabel.text = self.newsAsset.title;
blabel.adjustsFontSizeToFitWidth = NO;
blabel.autoresizingMask = UIViewAutoresizingFlexibleWidth;
blabel.font = [UIFont boldSystemFontOfSize:18.0];
blabel.textColor = [UIColor blueColor];
// alabel.shadowColor = [UIColor whiteColor];
// alabel.shadowOffset = CGSizeMake(0, 1);
blabel.backgroundColor = [UIColor clearColor];
blabel.lineBreakMode = UILineBreakModeWordWrap;
blabel.numberOfLines = 10;
blabel.minimumFontSize = 8.;
blabel.adjustsFontSizeToFitWidth = YES;
[blabel sizeToFit];
labelResizableView.autoresizingMask = UIViewAutoresizingFlexibleWidth;
// enable touch delivery
blabel.userInteractionEnabled = YES;
//tao gasture recognizer for label
UITapGestureRecognizer *doubleTap =[[UITapGestureRecognizer alloc] initWithTarget:self action:#selector(blabelTap:)];
doubleTap.numberOfTapsRequired = 2;
[blabel addGestureRecognizer:doubleTap];
UILongPressGestureRecognizer *longPressGesture = [[UILongPressGestureRecognizer alloc]
initWithTarget:self
action:#selector(longPress:)];
[longPressGesture setMinimumPressDuration:1];
[blabel addGestureRecognizer:longPressGesture];
//Calculate the expected size based on the font and linebreak mode of your label
CGSize maximumLabelSize = CGSizeMake(296,9999);
CGSize expectedLabelSize = [greetString sizeWithFont:blabel.font
constrainedToSize:maximumLabelSize
lineBreakMode:blabel.lineBreakMode];
//adjust the label the the new height.
CGRect newFrame = blabel.frame;
newFrame.size.height = expectedLabelSize.height+40;
newFrame.size.width = expectedLabelSize.width+40;
blabel.frame = newFrame;
labelResizableView.frame = newFrame;
labelResizableView.contentView = blabel;
labelResizableView.delegate = self;
labelResizableView.tag =2;
[self.view addSubview:labelResizableView];
}else if (theDataObject.count == 2) {
CGRect imageFrame = CGRectMake(10, 10, 150, 80);
labelResizableView = [[UserResizableView alloc] initWithFrame:imageFrame];
clabel = [[UILabel alloc] initWithFrame:CGRectMake(10, 35, 100, 100)];
clabel.text = #"Write here";
//alabel.text = self.newsAsset.title;
clabel.adjustsFontSizeToFitWidth = NO;
clabel.autoresizingMask = UIViewAutoresizingFlexibleWidth;
clabel.font = [UIFont boldSystemFontOfSize:18.0];
clabel.textColor = [UIColor blueColor];
// alabel.shadowColor = [UIColor whiteColor];
// alabel.shadowOffset = CGSizeMake(0, 1);
clabel.backgroundColor = [UIColor clearColor];
clabel.lineBreakMode = UILineBreakModeWordWrap;
clabel.numberOfLines = 10;
clabel.minimumFontSize = 8.;
clabel.adjustsFontSizeToFitWidth = YES;
[clabel sizeToFit];
labelResizableView.autoresizingMask = UIViewAutoresizingFlexibleWidth;
// enable touch delivery
clabel.userInteractionEnabled = YES;
//tao gasture recognizer for label
UITapGestureRecognizer *doubleTap =[[UITapGestureRecognizer alloc] initWithTarget:self action:#selector(clabelTap:)];
doubleTap.numberOfTapsRequired = 2;
[clabel addGestureRecognizer:doubleTap];
UILongPressGestureRecognizer *longPressGesture = [[UILongPressGestureRecognizer alloc]
initWithTarget:self
action:#selector(longPress:)];
[longPressGesture setMinimumPressDuration:1];
[clabel addGestureRecognizer:longPressGesture];
//Calculate the expected size based on the font and linebreak mode of your label
CGSize maximumLabelSize = CGSizeMake(296,9999);
CGSize expectedLabelSize = [greetString sizeWithFont:clabel.font
constrainedToSize:maximumLabelSize
lineBreakMode:clabel.lineBreakMode];
//adjust the label the the new height.
CGRect newFrame = blabel.frame;
newFrame.size.height = expectedLabelSize.height+40;
newFrame.size.width = expectedLabelSize.width+40;
clabel.frame = newFrame;
labelResizableView.frame = newFrame;
labelResizableView.contentView = clabel;
labelResizableView.delegate = self;
labelResizableView.tag=3;
[self.view addSubview:labelResizableView];
}
}
And when user long press button than it will be deleted...
- (void)longPress:(UILongPressGestureRecognizer *)longPressGesture {
if (longPressGesture.state == UIGestureRecognizerStateEnded) {
//NSLog(#"Long press Ended");
// NSLog(#"blabel long pressed");
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:#"Delete Label" message:#"Want delete label" delegate:self cancelButtonTitle:#"No" otherButtonTitles:#"Yes",nil];
[alert show];
}
else {
//NSLog(#"Long press detected.");
}
}
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
NSString *title = [alertView buttonTitleAtIndex:buttonIndex];
if([title isEqualToString:#"Yes"])
{
ExampleAppDataObject* theDataObject = [self theAppDataObject];
if (theDataObject.count!=0) {
theDataObject.count = theDataObject.count-1;
}
addLabel.enabled = YES;
[labelResizableView removeFromSuperview];
// NSLog(#"yes btn tapped");
}
}
but now when i longpree blabel than still clabel is deleted and it will never delete blabel.thanx in advance.
Use the Tag property to remove the labelResizableView.
-(void)addLabel:(id)sender
{
labelResizableView = [[UserResizableView alloc] initWithFrame:imageFrame];
labelResizableView.tag = 100;
}
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
NSString *title = [alertView buttonTitleAtIndex:buttonIndex];
if([title isEqualToString:#"Yes"])
{
ExampleAppDataObject* theDataObject = [self theAppDataObject];
if (theDataObject.count!=0) {
theDataObject.count = theDataObject.count-1;
}
addLabel.enabled = YES;
UILabel *tempLabel = (UILabel *)[self.view viewWithTag:100];
if(tempLabel)
[tempLabel removeFromSuperview];
}
}
hope this code help you :)
NSArray *subArray = [self.view subviews];
if([subArray count] != 0) {
for(int i = 0 ; i < [subArray count] ; i++) {
[[subArray objectAtIndex:i] removeFromSuperview];
}
}
To add control in your view:
[self.view addsubview:yourcontrolid];
ex:
[self.view addsubview:labelid];
To add control from your view:
[controlid removefromsuperview];
ex
[labelid removefromsuperview];
you are adding with :
[self.view addSubview:labelResizableView];
than remove it the labelResizableView, and release the clabel or blabel, whatever is in your case.
Maybe this gives an example
It is because your code
else if (theDataObject.count == 2) {
is calling and in this code you are adding
labelResizableView.contentView = clabel;
and then you are adding this to you view
[self.view addSubview:labelResizableView];
So when you are deleting labelResizableView
[labelResizableView removeFromSuperview];
So the result is you are adding labelResizableView 2 times and remove the labelResizableView which have clabel.
This question already has answers here:
Xcode - How to fix 'NSUnknownKeyException', reason: … this class is not key value coding-compliant for the key X" error?
(79 answers)
Closed 7 years ago.
Hey I can't figure out an error I got. I had my App working and then I'm not sure what I did but it won't open now and instead I get this error:
Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<TaskViewController 0x16c9b0> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key projectToolBar.'
Any Ideas what might be the problem? I can add my project code if I need to...
edit:
So i looked and in the interface builder/storyboard there was a link to projectToolBar that didn't have a corresponding line in the header file. I deleted the problem in IB, however, now I am getting a new error and it still isn't working.
*** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<TaskViewController 0x132dd0> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key projectView.'
Here is my taskviewController class:
#import <UIKit/UIKit.h>
#import "AppDelegate.h"
#import "newTaskWindow.h"
#interface TaskViewController : UIViewController <DismissPopoverDelegate>{
IBOutlet UIScrollView *taskScrollView;
AppDelegate * _appDelegate;
UIDeviceOrientation orientation;
IBOutlet UIView *newTaskView;
IBOutlet UIBarButtonItem *newTaskButton;
IBOutlet UIBarButtonItem *newTeamMemberButton;
IBOutlet UIBarButtonItem *newProjectButton;
IBOutlet UIView*taskView;
IBOutlet UIToolbar *taskToolBar;
NSMutableArray *teamMembers;
NSMutableArray *projects;
NSMutableArray *tasks;
//UIPopoverController *taskPop;
int countForX;
int countForY;
int xOffSet;
int yOffset;
int xMult;
int yMult;
int viewContentSize;
int countForTaskView;
int maxCountForX;
int maxCountForY;
int incrementForYOffset;
int viewContentSizeBase;
}
- (IBAction)newTask:(id)sender;
- (IBAction)newTeamMember:(id)sender;
- (IBAction)newProject:(id)sender;
-(void)setTasksInScreen;
#property(nonatomic, retain) AppDelegate * appDelegate;
#property (nonatomic, retain) UIPopoverController *myPopover;
#end
#protocol NewsVcDelegate <NSObject>
- (void)FirstViewController:(TaskViewController*)controller didSelectObject:(id)object;
#end
// FirstViewController.m
#import "TaskViewController.h"
#import "newTaskWindow.h"
#import "TeamMember.h"
#import "Project.h"
#import "newTeamMemberWindow.h"
#import "newProjectWindow.h"
#implementation TaskViewController
#synthesize myPopover;
#synthesize appDelegate;
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Release any cached data, images, etc that aren't in use.
}
#pragma mark - View lifecycle
- (void)viewDidLoad
{
NSLog(#"Made it to TaskViewController");
self.appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
[[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
[[NSNotificationCenter defaultCenter] addObserver: self selector: #selector(deviceOrientationDidChange:) name: UIDeviceOrientationDidChangeNotification object: nil];
[self setTasksInScreen];
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}
//create new Team member in popover myPopover
-(IBAction)newTeamMember:(id)sender{
if ([self.myPopover isPopoverVisible]) {
//using the setters and getters "goes thru the proper channels" when accessing objects
[self.myPopover dismissPopoverAnimated:YES];
} else {
newTeamMemberWindow *teamMemberWindow = [[newTeamMemberWindow alloc]init];
[teamMemberWindow setDelegate:self];
UIPopoverController *teamMemberPop = [[UIPopoverController alloc]initWithContentViewController:teamMemberWindow];
[teamMemberPop setDelegate:self];
[teamMemberPop setPopoverContentSize:CGSizeMake(300, 450)];
//NSLog(#"Got to 6");
self.myPopover = teamMemberPop;
[self.myPopover presentPopoverFromBarButtonItem:newTeamMemberButton permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
}
}
//Create new Project in popover myPopover
-(IBAction)newProject:(id)sender{
if ([self.myPopover isPopoverVisible]) {
//using the setters and getters "goes thru the proper channels" when accessing objects
[self.myPopover dismissPopoverAnimated:YES];
} else {
newProjectWindow *projectWindow = [[newProjectWindow alloc]init];
[projectWindow setDelegate:self];
UIPopoverController *projectPop = [[UIPopoverController alloc]initWithContentViewController:projectWindow];
[projectPop setDelegate:self];
[projectPop setPopoverContentSize:CGSizeMake(300, 450)];
self.myPopover = projectPop;
[self.myPopover presentPopoverFromBarButtonItem:newProjectButton permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
}
}
//Create new Task in popover myPopover
-(IBAction)newTask:(id)sender{
if ([self.myPopover isPopoverVisible])
{
[self.myPopover dismissPopoverAnimated:YES];
} else {
NSString* test1 = [[NSString alloc]initWithFormat:#"Robby"];
[teamMembers addObject:test1];
newTaskWindow *newTaskWin = [[newTaskWindow alloc]init];
[newTaskWin setDelegate:self];
UIView *test = [[UIView alloc]init];
[newTaskWin setTeamMembers:teamMembers];
test = newTaskWin.view;
UIPopoverController *taskPop = [[UIPopoverController alloc]initWithContentViewController:newTaskWin];
[taskPop setDelegate:self];
[taskPop setPopoverContentSize:CGSizeMake(300, 450)];
self.myPopover = taskPop;
[self.myPopover presentPopoverFromBarButtonItem:newTaskButton permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
}
}
-(void)setTasksInScreen{
//remove all views that were in The task view. If you don't do this, a new view is placed on top everytime you call setTasksInScreen method and the buttons begin to overlap.
for (UIView *view in [taskView subviews]) {
[view removeFromSuperview];
}
//The placement of the buttons is different depending on which orientation we are in. We handle this with an if statement
if((self.interfaceOrientation == UIInterfaceOrientationPortrait) || (self.interfaceOrientation == UIInterfaceOrientationPortraitUpsideDown)){
countForX = 0;
countForY = 0;
xOffSet = 27;
yOffset = 60;
maxCountForX = 3;
maxCountForY = 4;
incrementForYOffset = 911;
xMult = 250;
yMult = 210;
viewContentSize = 0;
countForTaskView = 1;
viewContentSizeBase = 911;
NSLog(#"Portrait view");
}
else{
countForX = 0;
countForY = 0;
maxCountForX = 4;
maxCountForY = 3;
incrementForYOffset = 654;
xOffSet = 41;
yOffset = 50;
xMult = 240;
yMult = 200;
viewContentSize = 0;
countForTaskView = 1;
viewContentSizeBase = 654;
NSLog(#"LandScape view");
}
//Create Scrollview to be able to scroll through the different tasks
taskScrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width,self.view.frame.size.height -45)];
tasks = [[NSMutableArray alloc] initWithArray:self.appDelegate.tasks];
Task *tempTask = [[Task alloc]init];
for(int i =0; i < [tasks count]; i++){
tempTask = [tasks objectAtIndex:i];
NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
//Set the style that you want the date to be here (ie. MM-DD-YYYY ect)
[formatter setDateStyle:NSDateFormatterFullStyle];
NSDate *endDateForButton = [tempTask endDate];
//Use custom Button so that you can add in background pic
UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
button.frame = CGRectMake(xOffSet+(countForX*xMult), yOffset +(countForY*yMult), 215, 156);
UIImage *buttonBackground = [UIImage imageNamed:#"rectangleImage.png"];
[button setBackgroundImage:buttonBackground forState:UIControlStateNormal];
//add labels to button for information
UILabel *taskName = [[UILabel alloc]initWithFrame:CGRectMake(5, 5, 200, 45)];
taskName.text = [tempTask taskName];
[taskName setTextAlignment:UITextAlignmentCenter];
[button addSubview:taskName];
//Label that says "Due on"
UILabel *dueLabel = [[UILabel alloc]initWithFrame:CGRectMake(5, 50, 200, 45)];
dueLabel.text = #"Due on";
[dueLabel setTextAlignment:UITextAlignmentCenter];
[button addSubview:dueLabel];
UILabel *endDate = [[UILabel alloc]initWithFrame:CGRectMake(5, 80, 200, 45)];
endDate.text = [formatter stringFromDate:[tempTask endDate]];
[endDate setTextAlignment:UITextAlignmentCenter];
[button addSubview:endDate];
countForX++;
if(countForX >= maxCountForX)
{
countForY++;
countForX = 0;
}
if(countForY >=maxCountForY)
{
countForY = 0;
countForX = 0;
yOffset +=incrementForYOffset;
countForTaskView++;
}
[taskScrollView addSubview:button];
}//for loop
[taskView addSubview:taskScrollView];
[taskView bringSubviewToFront:taskToolBar];
//[taskScrollView addSubview:viewForTaskScrollView];
viewContentSize = viewContentSizeBase * (countForTaskView);
taskScrollView.contentSize = CGSizeMake(taskView.frame.size.width, viewContentSize);
[taskScrollView setPagingEnabled:YES];
}
-(void)setProjectsInScreen{
//remove all views that were in The task view. If you don't do this, a new view is placed on top everytime you call setTasksInScreen method and the buttons begin to overlap.
for (UIView *view in [taskView subviews]) {
[view removeFromSuperview];
}
//The placement of the buttons is different depending on which orientation we are in. We handle this with an if statement
if((self.interfaceOrientation == UIInterfaceOrientationPortrait) || (self.interfaceOrientation == UIInterfaceOrientationPortraitUpsideDown)){
countForX = 0;
countForY = 0;
xOffSet = 27;
yOffset = 60;
maxCountForX = 3;
maxCountForY = 4;
incrementForYOffset = 911;
xMult = 250;
yMult = 210;
viewContentSize = 0;
countForTaskView = 1;
viewContentSizeBase = 911;
NSLog(#"Portrait view");
}
else{
countForX = 0;
countForY = 0;
maxCountForX = 4;
maxCountForY = 3;
incrementForYOffset = 654;
xOffSet = 41;
yOffset = 50;
xMult = 240;
yMult = 200;
viewContentSize = 0;
countForTaskView = 1;
viewContentSizeBase = 654;
NSLog(#"LandScape view");
}
//Create Scrollview to be able to scroll through the different tasks
taskScrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width,self.view.frame.size.height -45)];
projects = [[NSMutableArray alloc] initWithArray:self.appDelegate.projects];
Project *tempProject = [[Project alloc]init];
for(int i =0; i < [tasks count]; i++){
tempProject = [tasks objectAtIndex:i];
UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
button.frame = CGRectMake(xOffSet+(countForX*xMult), yOffset +(countForY*yMult), 215, 156);
UIImage *buttonBackground = [UIImage imageNamed:#"rectangleImage.png"];
[button setBackgroundImage:buttonBackground forState:UIControlStateNormal];
//add labels to button for information
UILabel *projectName = [[UILabel alloc]initWithFrame:CGRectMake(5, 5, 200, 45)];
projectName.text = [tempProject projectName];
[projectName setTextAlignment:UITextAlignmentCenter];
[button addSubview:projectName];
//Label that says "Due on"
UILabel *dueLabel = [[UILabel alloc]initWithFrame:CGRectMake(5, 50, 200, 45)];
dueLabel.text = #"Due on";
[dueLabel setTextAlignment:UITextAlignmentCenter];
[button addSubview:dueLabel];
countForX++;
if(countForX >= maxCountForX)
{
countForY++;
countForX = 0;
}
if(countForY >=maxCountForY)
{
countForY = 0;
countForX = 0;
yOffset +=incrementForYOffset;
countForTaskView++;
}
[taskScrollView addSubview:button];
}//for loop
[taskView addSubview:taskScrollView];
[taskView bringSubviewToFront:taskToolBar];
//[taskScrollView addSubview:viewForTaskScrollView];
viewContentSize = viewContentSizeBase * (countForTaskView);
taskScrollView.contentSize = CGSizeMake(taskView.frame.size.width, viewContentSize);
[taskScrollView setPagingEnabled:YES];
}
-(void)setTeamMembersInScreen{
//remove all views that were in The task view. If you don't do this, a new view is placed on top everytime you call setTasksInScreen method and the buttons begin to overlap.
for (UIView *view in [taskView subviews]) {
[view removeFromSuperview];
}
//The placement of the buttons is different depending on which orientation we are in. We handle this with an if statement
if((self.interfaceOrientation == UIInterfaceOrientationPortrait) || (self.interfaceOrientation == UIInterfaceOrientationPortraitUpsideDown)){
countForX = 0;
countForY = 0;
xOffSet = 27;
yOffset = 60;
maxCountForX = 3;
maxCountForY = 4;
incrementForYOffset = 911;
xMult = 250;
yMult = 210;
viewContentSize = 0;
countForTaskView = 1;
viewContentSizeBase = 911;
NSLog(#"Portrait view");
}
else{
countForX = 0;
countForY = 0;
maxCountForX = 4;
maxCountForY = 3;
incrementForYOffset = 654;
xOffSet = 41;
yOffset = 50;
xMult = 240;
yMult = 200;
viewContentSize = 0;
countForTaskView = 1;
viewContentSizeBase = 654;
NSLog(#"LandScape view");
}
//Create Scrollview to be able to scroll through the different tasks
taskScrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width,self.view.frame.size.height -45)];
tasks = [[NSMutableArray alloc] initWithArray:self.appDelegate.tasks];
Task *tempTask = [[Task alloc]init];
for(int i =0; i < [tasks count]; i++){
tempTask = [tasks objectAtIndex:i];
NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
//Set the style that you want the date to be here (ie. MM-DD-YYYY ect)
[formatter setDateStyle:NSDateFormatterFullStyle];
NSDate *endDateForButton = [tempTask endDate];
//Use custom Button so that you can add in background pic
UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
button.frame = CGRectMake(xOffSet+(countForX*xMult), yOffset +(countForY*yMult), 215, 156);
UIImage *buttonBackground = [UIImage imageNamed:#"rectangleImage.png"];
[button setBackgroundImage:buttonBackground forState:UIControlStateNormal];
//add labels to button for information
UILabel *taskName = [[UILabel alloc]initWithFrame:CGRectMake(5, 5, 200, 45)];
taskName.text = [tempTask taskName];
[taskName setTextAlignment:UITextAlignmentCenter];
[button addSubview:taskName];
//Label that says "Due on"
UILabel *dueLabel = [[UILabel alloc]initWithFrame:CGRectMake(5, 50, 200, 45)];
dueLabel.text = #"Due on";
[dueLabel setTextAlignment:UITextAlignmentCenter];
[button addSubview:dueLabel];
UILabel *endDate = [[UILabel alloc]initWithFrame:CGRectMake(5, 80, 200, 45)];
endDate.text = [formatter stringFromDate:[tempTask endDate]];
[endDate setTextAlignment:UITextAlignmentCenter];
[button addSubview:endDate];
countForX++;
if(countForX >= maxCountForX)
{
countForY++;
countForX = 0;
}
if(countForY >=maxCountForY)
{
countForY = 0;
countForX = 0;
yOffset +=incrementForYOffset;
countForTaskView++;
}
[taskScrollView addSubview:button];
}//for loop
[taskView addSubview:taskScrollView];
[taskView bringSubviewToFront:taskToolBar];
//[taskScrollView addSubview:viewForTaskScrollView];
viewContentSize = viewContentSizeBase * (countForTaskView);
taskScrollView.contentSize = CGSizeMake(taskView.frame.size.width, viewContentSize);
[taskScrollView setPagingEnabled:YES];
}
- (void) dismissPopover:(NSString *)data
{ /* Dismiss you popover here and process data */
[self.myPopover dismissPopoverAnimated:YES];
[self setTasksInScreen];
//[myPopover dismissPopoverAnimated:YES];
}
// Some method, when you create popover
-(BOOL)popoverControllerShouldDismissPopover:(UIPopoverController *)popoverController{
return YES;
}
-(void)popoverControllerDidDismissPopover:(UIPopoverController *)popoverController{
}
- (void)viewDidUnload
{
[super viewDidUnload];
// Release any retained subviews of the main view.
// e.g. self.myOutlet = nil;
}
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
}
- (void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
}
- (void)viewWillDisappear:(BOOL)animated
{
[super viewWillDisappear:animated];
}
- (void)viewDidDisappear:(BOOL)animated
{
[super viewDidDisappear:animated];
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return (interfaceOrientation == UIInterfaceOrientationPortrait || interfaceOrientation == UIInterfaceOrientationPortraitUpsideDown || interfaceOrientation == UIInterfaceOrientationLandscapeRight || interfaceOrientation == UIInterfaceOrientationLandscapeLeft);
}
- (void)deviceOrientationDidChange:(NSNotification *)notification {
[self setTasksInScreen];
}
#end
Most likely you have a xib file that houses a toolBar that is still connected to a (now nonexistent) outlet named projectToolBar.
You removed IBOutlet UIToolBar *projectToolBar; from your TaskViewController.h file.
You should think about using source control management, so you can see what you did. ;-)
Xcode 4 Guide - Managing Versions of Your Project
I'm betting you're trying to fill your TaskViewController using setValuesForKeysWithDictionary: or something like that, and projectToolBar isn't a valid #property in your view controller's header file.
It could also be what #MatthiasBauch said.
I had the same error after adding a few objects to a UITableViewCell on storyboard. Before that, the app was working perfectly.
I was able to resolve this issue by going Xcode > Preferences > Locations > Derived Data, ,opened the directory and deleted the folders with the app's name.
Hope my comment will be helpful for those come here later.
I have a class that implements "UIView" and inside - (void)drawRect:(CGRect)rect method I add some custom buttons to self. Inside a UIViewController I declare an instance of this view and i add it to self.view.
If i do this in - (void)viewDidLoad, everything works perfect, but if I create a method that is called when I push a button, and add that view to self.view, the buttons background is displayed after a few second. Till then only the name of the button appears written in white.
What do i do wrong?
Regards
#implementation CustomButton
#synthesize isPressed, buttonViewNumber;
- (id)initWithFrame:(CGRect)frame
title:(NSString *)title
tag:(int)tag
{
self = [super initWithFrame:frame];
if (self) {
[self setTitle:title forState:UIControlStateNormal];
[self setTag:tag];
self.titleLabel.font = [UIFont fontWithName:#"Helvetica" size:14];
self.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
self.contentEdgeInsets = UIEdgeInsetsMake(0, 5, 0, 0);
[self setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
[self setBackgroundImage:[[UIImage imageNamed:#"btn_white_add.png"] stretchableImageWithLeftCapWidth:20.0 topCapHeight:0.0] forState:UIControlStateNormal];
[self addTarget:self action:#selector(didSelect) forControlEvents:UIControlEventTouchUpInside];
self.isPressed = NO;
}
return self;
}
#implementation ButtonsView
#synthesize listOfButtons;
- (id)initWithFrame:(CGRect)frame bundle:(NSArray *)data
{
self = [super initWithFrame:frame];
if (self) {
self.backgroundColor = [UIColor clearColor];
listOfNames = [[NSArray arrayWithArray:data] retain];
listOfButtons = [[NSMutableArray alloc] init];
currentViewNumber = 0;
viewNumber = 0;
}
return self;
}
- (void)drawRect:(CGRect)rect
{
CGSize maximumLabelSize = CGSizeMake(300,24);
UIFont *buttonFont = [UIFont fontWithName:#"Helvetica" size:14.0];
float lineSize = 0;
float lineNumber = 0;
NSArray *listOfFrameX = [NSArray arrayWithObjects:
[NSString stringWithFormat:#"%d",FIRST_LINE_Y],
[NSString stringWithFormat:#"%d",SECOND_LINE_Y],
[NSString stringWithFormat:#"%d",THIRD_LINE_Y],
nil];
for (int i = 0; i < [listOfNames count]; i++) {
CGSize expectedLabelSize = [[[listOfNames objectAtIndex:i] objectForKey:#"name"] sizeWithFont:buttonFont
constrainedToSize:maximumLabelSize
lineBreakMode:UILineBreakModeTailTruncation];
if ((lineSize + expectedLabelSize.width) > 260) {
lineNumber++;
lineSize = 0;
}
if (lineNumber > 2) {
viewNumber ++;
lineSize = 0;
lineNumber = 0;
}
CGRect newFrame = CGRectMake(lineSize,
[[listOfFrameX objectAtIndex:lineNumber] floatValue],
expectedLabelSize.width+30,
24);
CustomButton *myButton = [[CustomButton alloc] initWithFrame:newFrame
title:[[listOfNames objectAtIndex:i] objectForKey:#"name"]
tag:[[[listOfNames objectAtIndex:i] objectForKey:#"id"] intValue]];
myButton.buttonViewNumber = viewNumber;
[listOfButtons addObject:myButton];
if (viewNumber == 0) {
[self addSubview:myButton];
}
lineSize += expectedLabelSize.width + 40;
[myButton release];
}
}
this way it works:
- (void)viewDidLoad
{
[super viewDidLoad];
placeholders = [[NSArray arrayWithObjects:
something,something, something,something,nil] retain];
CGRect frame = CGRectMake(10, 247, 300, 84);
buttonsView = [[ButtonsView alloc] initWithFrame:frame bundle:placeholders];
[self.view addSubview:buttonsView];
and like this is doesnt work:
- (void)getCompanyNames:(id)result
{
NSArray *listOfCompanies = (NSArray *)result;
CGRect frame = CGRectMake(10, 247, 300, 84);
buttonsView = [[ButtonsView alloc] initWithFrame:frame bundle:listOfCompanies];
[self.view addSubview:buttonsView];
}
i need to add the "buttonsView" object to self.view after the -viewDidLoad
drawRect: isn't exactly the place you should be creating subviews (Buttons are subviews) for your view. This should either go into initWithFrame: or awakeFromNib, depending on your view creation method: programmatically or using a nib.
I am trying to add a subview on ImageView control, I think, i have alloc view and dealloc view properly.This is my code.
for(int Count =0; Count < [list count]; Count++)
{
MapCallout *callout = [list objectAtIndex:Count];
CGSize constSize = { 700.0f, 40.0f };
NSString * sTmp = [callout.Name stringByAppendingString:#"WW"];
CGSize textSize = [sTmp sizeWithFont:[UIFont fontWithName:#"Arial-BoldMT" size:25.0] constrainedToSize:constSize lineBreakMode:UILineBreakModeClip];
int xValue = callout.X;
int yValue = callout.Y;
int position = 0;
UIImage *calloutImage;
if(callout.Direction==0)
{
calloutImage=[UIImage newImageFromResource:#"arrow-0.png"];
callout.Y=callout.Y-3; position= -3;
}
else if(callout.Direction==1)
{
calloutImage=[UIImage newImageFromResource:#"arrow-1.png"];
callout.Y=callout.Y-3; position= -3;
}
else if(callout.Direction==2)
{
callout.Y=callout.Y + 2;
calloutImage=[UIImage newImageFromResource:#"arrow_2.png"];
position= +2;
}
CalloutButton *calloutButton = nil;
int arraySize = [dequeueReusableCallout count] - 1;
if(Count > arraySize)
{
calloutButton = [[[CalloutButton alloc]initWithFrame:CGRectMake(xValue,
self.tapDetectingImageView.frame.origin.y + yValue ,
textSize.width,40)] autorelease];
[calloutButton setDelegate:self];
[dequeueReusableCallout addObject:calloutButton];
}
calloutButton = [dequeueReusableCallout objectAtIndex:Count];
[calloutButton setFrame:CGRectMake(xValue,
self.tapDetectingImageView.frame.origin.y + yValue ,
textSize.width,40)] ;
[calloutButton setBackgroundImage:calloutImage andText:callout.Name andYvalue:position];
calloutButton.tag = callout.ID;
calloutButton.ViewMapType = [callout.calloutType intValue];
calloutButton.isLive = callout.isLive;
calloutButton.isAnimated = callout.isAnimated;
[self.tapDetectingImageView addSubview:calloutButton];
}
//Callout Button Method
-(void) setBackgroundImage:(UIImage*)image andText:(NSString*)text andYvalue:(double)Y
{
if(!btnCallout)
btnCallout = [[UIButton alloc] init];
[btnCallout setFrame:CGRectMake(0, -Y, self.frame.size.width, self.frame.size.height)];
[btnCallout setBackgroundImage:image forState:UIControlStateNormal];
[btnCallout addTarget:self action:#selector(CalloutTouch:) forControlEvents:UIControlEventTouchUpInside];
[self addSubview:btnCallout];
if(!lblCallout)
lblCallout = [[UILabel alloc] init];
[lblCallout setFrame:CGRectMake(0, 0, self.frame.size.width, self.frame.size.height)];
lblCallout.backgroundColor = [UIColor clearColor];
lblCallout.font = [UIFont systemFontOfSize:42.0];
lblCallout.userInteractionEnabled = NO;
lblCallout.text = text;
lblCallout.textAlignment = UITextAlignmentCenter;
lblCallout.font = [UIFont fontWithName:#"Arial-BoldMT" size:25.0];
[self addSubview:lblCallout];
}
[self viewForZoomingInScrollView:self.mapScrollView];
}
If i call this method method multi-times, memory warning is occur and app get crash.
Here, [self.tapDetectingImageView addSubview:calloutButton]; I if comment this statement, it is working properly. Please let me know where i am wrong.
You should call [calloutButton release] after you add it to the dequeueReusableCallout array since the array now has a retain on the newly allocated instance