Работа над раскадровки.Как отправить массив в subview, а затем распечатать на этикетке?
Я создал View Controller (раскадровка), а затем в середине контента, добавленного subview из файла xib.
Я хочу добавить xib (UIView), как подзаголовок в ViewController, и отправить объект с данными и распечатать эти данные в метку, но я не знаю, как это сделать.
Вот мой код.
ViewController.h
#import <UIKit/UIKit.h>
@interface ViewController : UIViewController {
UIView *subView;
}
@property (strong, nonatomic) IBOutlet UIView *subView; //connected over IB
@end
ViewController.m
#import "OfferViewController.h"
#import "OfferLocation.h"
@interface OfferViewController()
@end
@implementation OfferViewController
@synthesize subView;
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
OfferLocation *location = [[OfferLocation alloc] initWithFrame:CGRectZero];
[self.subView addSubview:location];
}
...
@end
и вот подтаблицы: OfferLocation.h
#import <UIKit/UIKit.h>
@interface OfferLocation : UIView{
UIView *view;
UILabel *locationLabel;// here is that label taht I want to print into
}
@property (nonatomic, retain) IBOutlet UIView *view;// connected over IB
@property (nonatomic, retain) IBOutlet UILabel *locationLabel;
@end
OfferLocation.m
#import "OfferLocation.h"
@implementation OfferLocation
@synthesize view, locationLabel;
- (id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self)
{
locationLabel.text = @"some text"; //this is not working
NSArray *subviewArray = [[NSBundle mainBundle] loadNibNamed:@"OfferLocation" owner:self options:nil];
UIView *tempView = [subviewArray objectAtIndex:0];
[self addSubview:tempView];
}
return self;
}
Я создал вместо UIView, новый UIViewController (OfferLocation), а затем редактировать только верхнюю часть этого нового контроллера представления и добавить как подвид к середине ViewController.h. Это верно? OfferLocation (UIVIewController) is: http://dl.dropbox.com/u/77033905/subview%20ss.png Я использую зеленую часть как subview. – CroiOS
Это не нормально, я правильно понял. В IB я просто удалил вид отказа и добавил UIView из библиотеки объектов, и теперь все в порядке. Мне нужна помощь в этой проблеме, и я помогу. – CroiOS