iOS Image View turn off selection highlighting - ios

Bit of a strange question, so i've attached a screen recording to help...
Video : https://www.dropbox.com/s/3aaefixsk8eejln/Error.mov (See past the watermark!)
My issue is that in my application when the user is at the "Preview" view and is reviewing their images, each time the image is selected, the image receives a touched overlay, which could be confusing for a user as nothing happens when touched.
I would like to disable this if possible..
Below is the example code to how the images are being displayed..
- (void)setReviewImages
{
continueButtonDisabled = YES;
downloadedImageCount = 0;
NSArray *reviewViews = scrollView.subviews;
for (IMReviewView *reviewView in reviewViews) {
[reviewView removeFromSuperview];
}
NSUInteger photoCount = [[IMLocalUser localUser] cachedPhotoCount];
if ( nPageNum == 0 ){
for (NSUInteger i = 0; i < photoCount; i++) {
CGRect frame;
frame.origin.x = scrollView.frame.size.width * i;
frame.origin.y = 65;
frame.size = CGSizeMake(scrollView.frame.size.width, 327.0f);
IMReviewView *subview = [[IMReviewView alloc] initWithFrame:frame];
subview.delegate = self;
subview.photo = [[IMLocalUser localUser] cachedPhotoAtIndex:i];
[scrollView addSubview:subview];
scrollView.showsHorizontalScrollIndicator = NO;
scrollView.contentSize = CGSizeMake(scrollView.frame.size.width * i, scrollView.frame.size.height);
UILabel *headingLabel = [[UILabel alloc] initWithFrame:CGRectMake(12, 20, 300, 30)];
[self.view addSubview:headingLabel];
headingLabel.text = #"Time To Preview!";
headingLabel.textColor = [UIColor blackColor];
headingLabel.textAlignment = UITextAlignmentCenter;
headingLabel.textAlignment = NSTextAlignmentCenter;
headingLabel.tag = 10;
headingLabel.backgroundColor = [UIColor clearColor];
headingLabel.font = [UIFont boldSystemFontOfSize:26.0f];
headingLabel.hidden = NO;
headingLabel.highlighted = YES;
headingLabel.highlightedTextColor = [UIColor blackColor];
headingLabel.lineBreakMode = YES;
headingLabel.numberOfLines = 0;
}

It seems to me like IMReviewView has a UIButton subview. If so, try to set its adjustsImageWhenHighlighted property to NO.

Related

UITapGestureRecognizer not working, Objective-C

I apologize for asking this question for the millionth time, I've read the other questions asking the same thing and I couldn't find the answer to my problem!
I made a UITapGestureRecognizer that is just not working, can someone take a look at my code and tell me what I'm doing wrong?
-(void) formatCellForY: (CGFloat) y{
CGRect screen = [[UIScreen mainScreen] bounds];
CGFloat cellHeight = 70;
self.cell = [[UIImageView alloc] initWithImage:[UIImage imageNamed: #"Cell"]];
[self.cell setFrame:CGRectMake(20, y, screen.size.width - 40, cellHeight)];
self.cell.backgroundColor = [UIColor grayColor];
self.cell.userInteractionEnabled = YES;
self.cell.layer.shadowColor = [UIColor blackColor].CGColor;
self.cell.layer.shadowOffset = CGSizeMake(0, 1);
self.cell.layer.shadowOpacity = 1.0;
self.cell.layer.shadowRadius = 1.0;
self.cell.layer.cornerRadius = 1.0;
self.cell.clipsToBounds = NO;
UILabel *titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(20, 5, self.cell.frame.size.width - 40, cellHeight*(.4))];
titleLabel.numberOfLines = 32;
titleLabel.text = self.program.programName;
titleLabel.textColor = [UIColor whiteColor];
titleLabel.userInteractionEnabled = YES;
[self.cell addSubview:titleLabel];
UILabel *explanationLabel = [[UILabel alloc] initWithFrame:CGRectMake(20, titleLabel.frame.origin.y + titleLabel.frame.size.height, titleLabel.frame.size.width, cellHeight - (titleLabel.frame.origin.y+ titleLabel.frame.size.height))];
explanationLabel.text = self.program.programDescription;
explanationLabel.numberOfLines = 3;
explanationLabel.textColor = [UIColor whiteColor];
explanationLabel.font = [UIFont systemFontOfSize:10.0];
explanationLabel.userInteractionEnabled = YES;
[self.cell addSubview:explanationLabel];
self.tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:#selector(goToInfoPage:)];
self.tap.numberOfTapsRequired = 1;
self.tap.numberOfTouchesRequired = 1;
self.tap.enabled = YES;
[self.cell addGestureRecognizer:self.tap];
NSLog(#"%#", self.tap);
}
Here is the code I used to add the cell to the screen.
for (CKRecord *record in records) {
SBHProgram *program = [SBHProgram programForRecord:record];
SBHCell *cell = [SBHCell cellForProgram:program andY:90*i];
i++;
[scrollView addSubview:cell.cell];
}
You have missed adding self.cell to view. You are able to see labels with texts because you have added self.cell.clipsToBounds = NO;
All you have to do is add cell to view.
[self.view addSubview:self.cell]
PLEASE ADD
self.tap.delegate = self;

iOS FadeIn/FadeOut during paging

I have an UIScrollView with views inside that I can scroll horizontally. During the scroll I would like to add a fade out on the view which is going out of the screen and a fade in on the view which is going in the screen.
Here my code :
for (int i = 0; i <textEntries.count; i++)
{
CGRect frame;
frame.origin.x = self.scrollView.frame.size.width * i + 5;
frame.size.width = self.scrollView.frame.size.width - 10;
frame.size.height = self.scrollView.frame.size.height - 10;
self.scrollView.pagingEnabled = YES;
UIView *subview = [[UIView alloc] initWithFrame:frame];
if([[colorEntries objectAtIndex:i] isEqualToString:#"violet"]){
subview.backgroundColor = [UIColor colorWithRed:(147/255.0) green:(90/255.0) blue:(255/255.0) alpha:1];
} else {
subview.backgroundColor = [UIColor colorWithRed:(100/255.0) green:(166/255.0) blue:(255/255.0) alpha:1];
}
subview.layer.cornerRadius = 5;
[self.scrollView addSubview:subview];
UITextView *noteLabel = [[UITextView alloc] init];
noteLabel.frame = CGRectMake(0, 0, self.scrollView.frame.size.width - 20, self.scrollView.frame.size.height -20);
noteLabel.text = [textEntries objectAtIndex:i];
noteLabel.userInteractionEnabled = NO;
noteLabel.backgroundColor = [UIColor clearColor];
noteLabel.contentInset = UIEdgeInsetsMake(20,20,20,20);
noteLabel.font = [UIFont fontWithName:#"HelveticaNeue-Bold" size:40];
[noteLabel setTextColor:[UIColor whiteColor]];
[subview addSubview:noteLabel];
[noteLabel addObserver:self forKeyPath:#"contentSize" options:(NSKeyValueObservingOptionNew) context:NULL];
}
Could you help me to build this fadeIn/FadeOut effect ?
Thanks!

Image slider pages printing issue?

I'm trying to create image slider view to view 3 pictures as slider. But every time it is creating only one picture with 3 slides. So please where would be my issue?
Should it print an image in each page slide?
- (void)imageCreater{
self.view.backgroundColor = [UIColor whiteColor];
self.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
CGRect svrect_ = CGRectZero;
svrect_.size.height = self.view.bounds.size.height/3*2;
svrect_.size.width = self.view.bounds.size.width/3*2;
CGPoint svcenter_ = CGPointZero;
svcenter_.x = self.view.center.x;
svcenter_.y = self.view.center.y+45;
CGSize svconsize = CGSizeZero;
svconsize.height = svrect_.size.height;
svconsize.width = svrect_.size.width * 3;
CGPoint pgconcenter_ = CGPointZero;
pgconcenter_.x = self.view.center.x;
pgconcenter_.y = svcenter_.y + (svrect_.size.height/2) + 20;
CGRect btnrect_ = CGRectZero;
btnrect_.size.width = 250;
btnrect_.size.height = 50;
CGPoint btncenter_ = CGPointZero;
btncenter_.x = self.view.center.x;
btncenter_.y = self.view.bounds.size.height-65;
_backgroundimageview = [[UIImageView alloc] initWithFrame:self.view.bounds];
[self.view addSubview:_backgroundimageview];
_scrollview = [[UIScrollView alloc] initWithFrame:svrect_];
_scrollview.center = svcenter_;
_scrollview.backgroundColor = [UIColor whiteColor];
_scrollview.contentSize = svconsize;
_scrollview.pagingEnabled = true;
_scrollview.bounces = false;
_scrollview.delegate = self;
_scrollview.showsHorizontalScrollIndicator = false;
_scrollview.layer.cornerRadius = 2;
[self.view addSubview:_scrollview];
_pgcontrol = [[UIPageControl alloc] initWithFrame:CGRectZero];
_pgcontrol.pageIndicatorTintColor = [UIColor colorWithWhite:0.8 alpha:1];
_pgcontrol.currentPageIndicatorTintColor = [UIColor colorWithWhite:0.6 alpha:1];
_pgcontrol.numberOfPages = 3;
_pgcontrol.currentPage = 0;
[_pgcontrol sizeToFit];
_pgcontrol.center = pgconcenter_;
[self.view addSubview:_pgcontrol];
UIImageView*iv_ = [[UIImageView alloc] initWithFrame:svrect_];
iv_.contentMode = UIViewContentModeScaleAspectFit;
iv_.clipsToBounds = true;
iv_.image = [UIImage imageNamed:#"31902.png"];
UIImageView*iv1_ = [[UIImageView alloc] initWithFrame:svrect_];
iv1_.contentMode = UIViewContentModeScaleAspectFit;
iv1_.clipsToBounds = true;
iv1_.image = [UIImage imageNamed:#"31901.png"];
UIImageView*iv2_ = [[UIImageView alloc] initWithFrame:svrect_];
iv2_.contentMode = UIViewContentModeScaleAspectFit;
iv2_.clipsToBounds = true;
iv2_.image = [UIImage imageNamed:#"31900.png"];
[_scrollview addSubview:iv_];
[_scrollview addSubview:iv1_];
[_scrollview addSubview:iv2_];
}
-(void)scrollViewDidScroll:(UIScrollView *)scrollView{
int page_ = (int)round(scrollView.contentOffset.x / scrollView.frame.size.width);
if (page_== inter-1) {
[_button setTitle:startText forState:UIControlStateNormal];
}else{
[_button setTitle:nextText forState:UIControlStateNormal];
}
_pgcontrol.currentPage = page_;
}
You are setting the same frame to the three imageView
Change the frame as mentioned below, you will get three image in slideView
UIImageView*iv_ = [[UIImageView alloc] initWithFrame:svrect_];
iv_.contentMode = UIViewContentModeScaleAspectFit;
iv_.clipsToBounds = true;
iv_.image = [UIImage imageNamed:#"images-1.jpg"];
svrect_.origin.x += iv_.frame.size.width;
UIImageView*iv1_ = [[UIImageView alloc] initWithFrame:svrect_];
iv1_.contentMode = UIViewContentModeScaleAspectFit;
iv1_.clipsToBounds = true;
iv1_.image = [UIImage imageNamed:#"images-2.jpg"];
svrect_.origin.x += iv1_.frame.size.width;
UIImageView*iv2_ = [[UIImageView alloc] initWithFrame:svrect_];
iv2_.contentMode = UIViewContentModeScaleAspectFit;
iv2_.clipsToBounds = true;
iv2_.image = [UIImage imageNamed:#"images-3.jpg"];
[_scrollview addSubview:iv_];
[_scrollview addSubview:iv1_];
[_scrollview addSubview:iv2_];

Adding a tag to UIImageView

I have an array of an object (which contains an image and some text) and when I iterate around the array and add the image to a UIImageView (which is then added to a UIScrollView) all works well and each image is added with a specific UIImageView to the UIScrollView.
However as soon as I add a tag to the UIImageView not all the images are rendered within the added UIImageView (which is in the UIScrollView (some are missing, some are visible).
If I remove the tag, all works well? Is there something with tags I'm not grasping? Any help much appreciated.
for (Article *al in articleLists){
CGRect frame;
frame.origin.x = self.FeaturedView.frame.size.width * counter;
frame.origin.y = 0;
frame.size = self.FeaturedView.frame.size;
CGRect frameTextArea;
frameTextArea.origin.x = self.FeaturedView.frame.size.width * counter;
frameTextArea.origin.y = (self.FeaturedView.frame.size.height / 2) + 10;
frameTextArea.size.width = self.FeaturedView.frame.size.width;
frameTextArea.size.height = (self.FeaturedView.frame.size.height / 2) - 20;
CGRect frameTextLabel;
frameTextLabel.origin.x = (self.FeaturedView.frame.size.width * counter) + 20;
frameTextLabel.origin.y = (self.FeaturedView.frame.size.height / 2) + 10;
frameTextLabel.size.width = self.FeaturedView.frame.size.width - 40;
frameTextLabel.size.height = (self.FeaturedView.frame.size.height / 2) - 20;
if (al.imageURL != NULL){
UIImageView *imageView = [[UIImageView alloc] initWithFrame:frame];
imageView.contentMode = UIViewContentModeScaleAspectFill;
//imageView.tag = counter;
imageView.image = al.imageArticle;
UITapGestureRecognizer *imageTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:#selector(singleTapGestureCaptured:)];
[imageView addGestureRecognizer:imageTap];
imageView.userInteractionEnabled = YES;
UIView *viewTextArea = [[UIView alloc]initWithFrame:frameTextArea];
viewTextArea.backgroundColor = [UIColor blackColor];
viewTextArea.alpha = 0.9;
UILabel *textLabel = [[UILabel alloc] initWithFrame:frameTextLabel];
textLabel.textColor = [UIColor whiteColor];
textLabel.backgroundColor = [UIColor clearColor];
textLabel.numberOfLines = 2;
textLabel.font = [UIFont fontWithName:#"Droid Sans" size:18];
textLabel.text = [al.currentTitle uppercaseString];
[self.FeaturedView addSubview:imageView];
[self.FeaturedView addSubview:viewTextArea];
[self.FeaturedView addSubview:textLabel];
}
else{
//UIImage *image = [UIImage imageNamed:#"ArticlePlaceholder.png"];
}
counter++;
}

Change text on swipe

I am creating a text jokes app what i need is i want the UITextView in swipe form like when i swipe the first joke after a gap another UITextview comes in with another joke , so far what i have done is i have manually created the UITextView ( like if there is 10 jokes then 10 uitextview ) and added them in a scroll but that is taking too much time in viewdidload method and the app takes 6,7 second to load ...
if you have anyother idea please do let me know
for (int i = 0; i < arrresult.count; i++) {
CGRect frame;
frame.origin.x = self.scrollmain.frame.size.width * i;
frame.origin.y = 0;
frame.size = self.scrollmain.frame.size;
// UITextView *subview = [[UITextView alloc] initWithFrame:CGRectMake((frame.origin.x)+40,(frame.origin.y)+10, 230, 120)];
// UITextView *subview2 = [[UITextView alloc]initWithFrame:CGRectMake((frame.origin.x)+40,(frame.origin.y)+160,230, 120)];
UITextView *subview = [[UITextView alloc] initWithFrame:CGRectMake((frame.origin.x)+40,(frame.origin.y)+10, 230, 120)];
UITextView *subview2 = [[UITextView alloc]initWithFrame:CGRectMake((frame.origin.x)+40,(frame.origin.y)+160,230, 120)];
subview.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:#"BG_text.png"]];
subview2.backgroundColor = [UIColor whiteColor];
[subview setFont:[UIFont boldSystemFontOfSize:14]];
[subview2 setFont:[UIFont boldSystemFontOfSize:14]];
subview.layer.cornerRadius = 10 ;
subview2.layer.cornerRadius = 10;
NSString *p = [duaobj2 dua_arabic];
NSString *b = [duaobj2 eng_trans];
subview.text = p;
subview2.text = b;
[self.scrollmain addSubview:subview];
[self.scrollmain addSubview:subview2];
subview.editable = NO;
subview2.editable = NO;
subview.textColor = [UIColor blackColor];
subview2.textColor = [UIColor blackColor];
subview.backgroundColor = [UIColor whiteColor];
subview2.backgroundColor = [UIColor whiteColor];
scrollmain.showsHorizontalScrollIndicator = NO;
CGRect frame1 = subview.frame;
CGRect frame2 = subview2.frame;
frame1.size.height = subview.contentSize.height;
frame2.size.height = subview2.contentSize.height;
subview.frame = frame1;
subview2.frame = frame2;
}
self.scrollmain.contentSize = CGSizeMake(self.scrollmain.frame.size.width * arrresult.count,self.scrollmain.frame.size.height);
scrollmain.pagingEnabled = TRUE;
scrollmain.delegate = self;
There is no need to load the subviews at the time of viewDidLoad.
You should delay this by using scrollView delegate methods.
You should create only 3 textviews at max. Current, previous and next.
On scrollViewDidScroll delegate method, you should wisely remove previously loaded textview and you should add new textview.

Resources