Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 04-08-2011, 01:47 AM   #1 (permalink)
Registered Member
 
Join Date: Apr 2011
Posts: 9
Grance is on a distinguished road
Default Horizontal UIScrollView like in BBC News app?

Hello!
Im trying to make News scroll like in BBC News app
bbc-news-app.jpg

I've made class Slider: UIScrollView and custom TapView: UIView for every news entry.
Its working but I cant access to my TapView to change title label or description label from Slider or ViewController.
So in my custom UIView class TapView i have this:

Code:
@interface TapView : UIView {
	NSString *titleFeed; // Name of the source feed
	NSString *img; // Feed entry image
	NSString *description; // Feed entry title
	NSString *url; // Feed entry url
	UILabel *titleView;
	UILabel *descView;
	UIImageView *imageView;
	BOOL isActive;
}
@property (retain) NSString *titleFeed;
@property (retain) NSString *img;
@property (retain) NSString *description;
@property (retain) NSString *url;
@property (retain) UILabel *titleView;
@property (retain) UILabel *descView;
@property (retain) UIImageView *imageView;
@property (nonatomic, assign) BOOL isActive;
In implementition i have:

Code:
@synthesize titleFeed, img, description, url, titleView, descView, imageView, isActive;

- (id)initWithFrame:(CGRect)frame {
    
    CGRect newFrame = CGRectMake(0.0f, 0.0f, 160, 200);
	
	self = [super initWithFrame:newFrame];
    if (self) {

		CGRect titleViewFrame = CGRectMake(10.0f, 0.0f, 150, 15);
		CGRect imageViewFrame = CGRectMake(0.0f, 20.0f, 160, 96);
		CGRect descriptionViewFrame = CGRectMake(10.0f, 120.0f, 150, 39);

		UILabel *temptitleView = [[UILabel alloc] initWithFrame:titleViewFrame];
		self.titleView = temptitleView;
		[temptitleView release];

		UIImageView *tempimageView = [[UIImageView alloc] initWithFrame:imageViewFrame];
		self.imageView = tempimageView;
		[tempimageView release];

		UILabel *tempdescView = [[UILabel alloc] initWithFrame:descriptionViewFrame];
		self.descView = tempdescView;
		[tempdescView release];
		
		[self addSubview:titleView];
		[self addSubview:imageView];
		[self addSubview:descView];
	}
    return self;
}
Cant get access to my UILabels text property. its not changing some how. Any ideas?
Or maybe you know how to organize code more efficiency?

Last edited by Grance; 04-08-2011 at 01:58 AM.
Grance is offline   Reply With Quote
Old 04-08-2011, 03:44 AM   #2 (permalink)
Nuisance Developer
 
Join Date: Jul 2009
Location: Italy
Posts: 4,691
dany_dev is on a distinguished road
Default

what mean exactly that you can't access UILabel? can you do an example of what are not working?
__________________
dany_dev is offline   Reply With Quote
Old 04-08-2011, 04:05 AM   #3 (permalink)
Registered Member
 
Join Date: Apr 2011
Posts: 9
Grance is on a distinguished road
Default

for example in my ViewController i've added:
Code:
TapView *t = [[TapView alloc] initWithFrame:scrollViewRect];
		NSString *p = @"Lalala";
		t.titleView.text = p;
                t.descView.text = p;
		[self.scrollView addSubview:t];
		[t release];
UILabels are empty
Grance is offline   Reply With Quote
Old 04-08-2011, 04:57 AM   #4 (permalink)
Registered Member
 
Join Date: Apr 2011
Posts: 9
Grance is on a distinguished road
Default

NSLog(@"%@, %@", t.feedLabel.text, t.descView.text);

show me that both of them have that NSString p value, but they dont show-up on the screen.

*I've figured out that I needed to init UILabels with empty strings, now it's working

1. But how do you think am I need all this NSStrings in class TapView, or it is better do access directly to UILabels of TapView class?

2. If I have an array of TapViews, and user touched one of them how can I make it active (for example i can make border around touched TapView)? I'll have to loop through all of them except that one thouched and their borders to none? Or there is more simple way to check it?
Grance is offline   Reply With Quote
Old 04-08-2011, 05:22 AM   #5 (permalink)
Nuisance Developer
 
Join Date: Jul 2009
Location: Italy
Posts: 4,691
dany_dev is on a distinguished road
Default

i think was a problem related to update your view (with a setNeedDisplay), but i'm not sure, if someone know why worked only after initialized with a string, i wish to know .

1) yes, you should access directly the label, create a NSString for that doesn't make sense, you can do a method if you need to do some checks before setting text.
2) you should do the opposite, draw a rect on your custom UIView when user tap it.
__________________

Last edited by dany_dev; 04-08-2011 at 05:35 AM.
dany_dev is offline   Reply With Quote
Old 04-08-2011, 11:58 AM   #6 (permalink)
Registered Member
 
Join Date: Apr 2011
Posts: 9
Grance is on a distinguished road
Default

ok! Thank you for reply!
Grance is offline   Reply With Quote
Old 04-10-2011, 01:44 AM   #7 (permalink)
Registered Member
 
Join Date: Apr 2011
Posts: 9
Grance is on a distinguished road
Default

I have one more question ^)

If i have TapView button and I have url stored in that class with how can I pass it from TapView to UIWebView class throught UIViewController?



Some delegate methods or there is a simpler better way?
Grance is offline   Reply With Quote
Old 04-13-2011, 09:53 AM   #8 (permalink)
Registered Member
 
Join Date: Apr 2011
Posts: 9
Grance is on a distinguished road
Default

Anyone?
How can i make working delegation?
Grance is offline   Reply With Quote
Old 04-13-2011, 12:04 PM   #9 (permalink)
Nuisance Developer
 
Join Date: Jul 2009
Location: Italy
Posts: 4,691
dany_dev is on a distinguished road
Default

how you "intercept" the touch on your TapView?
__________________
dany_dev is offline   Reply With Quote
Old 04-13-2011, 12:58 PM   #10 (permalink)
Registered Member
 
Join Date: Apr 2011
Posts: 9
Grance is on a distinguished road
Default

Holly cow! I've get it working while writing answer to you Thank you!

Last edited by Grance; 04-13-2011 at 01:01 PM.
Grance is offline   Reply With Quote
Old 04-13-2011, 01:27 PM   #11 (permalink)
Nuisance Developer
 
Join Date: Jul 2009
Location: Italy
Posts: 4,691
dany_dev is on a distinguished road
Default

__________________
dany_dev is offline   Reply With Quote
Reply

Bookmarks

Tags
objective-c, uiscrollvew, uiview

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 357
13 members and 344 guests
dansparrow, dre, ilmman, LezB44, michelle, Nobbsy, Objective Zero, samdanielblr, Sami Gh, shagor012, sledzeppelin, thephotographer, tinamm64
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,663
Threads: 94,119
Posts: 402,896
Top Poster: BrianSlick (7,990)
Welcome to our newest member, LezB44
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 01:41 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0