Tuesday, 29 October 2013

Action on UILabel in iphone

[titleLbl setUserInteractionEnabled:YES];
UITapGestureRecognizer *tapGestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(labelButton:)];
[tapGestureRecognizer setNumberOfTapsRequired:1];
[titleLbl addGestureRecognizer:tapGestureRecognizer];

[tapGestureRecognizer release];

Friday, 4 October 2013

UIScrollview Autolayout Issue

.h file

@property (assign,nonatomic) CGPoint scrollviewContentOffsetChange;

.m file

- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
    self.scrollView.contentOffset = CGPointZero;
}

- (void)viewWillDisappear:(BOOL)animated {
    [super viewWillDisappear:animated];
    self.scrollviewContentOffsetChange = self.scrollView.contentOffset;
}

- (void)viewDidLayoutSubviews {
    [super viewDidLayoutSubviews];
     self.scrollView.contentOffset = self.scrollviewContentOffsetChange;
}