我正在使用objective-c在Xcode中开发一个应用程序。我的问题是我想连接一个名为phoneTextView
的TextView和代码,但是Xcode说我“非法配置:从RestViewController到UITextView的phoneTextView插座无效.Outlets无法连接到重复内容”我有一个UIViewController调用了RestViewController
,在UIViewController里面我有一个TableView。在这个TableView中,我想将TextView放在单元格中。
TextView应根据TitleLabel
中的RestViewController.m
进行更改。
有办法吗?
这是我的RestViewController.h:
#import <UIKit/UIKit.h>
#import "Restaurant.h"
@interface RestViewController : UIViewController <UITableViewDelegate, UITableViewDataSource>
@property (strong, nonatomic) IBOutlet UILabel *TitleLabel;
@property (strong, nonatomic) IBOutlet UILabel *DescriptionLabel;
@property (strong, nonatomic) IBOutlet UIImageView *ImageView;
@property (strong, nonatomic) IBOutlet UIImageView *headerImage;
@property (weak, nonatomic) IBOutlet UITextView *phoneTextView;
@property (weak, nonatomic) IBOutlet UIButton *webButton;
@property (nonatomic, strong) Restaurant *DetailModal;
@property (strong, nonatomic) IBOutlet UITableView *myTableView;
@end
这是我的RestViewController.m:
#import "RestViewController.h"
#import <QuartzCore/QuartzCore.h>
#import <CoreGraphics/CoreGraphics.h>
#import "RestDetailsTableViewCell.h"
@interface RestViewController ()
@end
@implementation RestViewController {
NSArray *cellsIdentifier;
}
- (void)viewDidLoad {
[super viewDidLoad];
NSString *decDate = @"12/2016";
self.myTableView.dataSource = self;
self.myTableView.delegate = self;
cellsIdentifier = @[@"first", @"second", @"third", @"fourth"];
self.myTableView.tableFooterView = [[UIView alloc] init]; /*Esta linea hace que en la tabla solo aparezcan el numero de filas que tienes establecidas, es decir, que las vacias no aparezcan*/
_ImageView.layer.borderWidth = 1;
_ImageView.layer.cornerRadius = 6;
_ImageView.clipsToBounds = YES;
if ([_DetailModal.title isEqualToString:@"80 Grados"]) {
_headerImage.image = [UIImage imageNamed:@"80_grados_head.jpg"];
_TitleLabel.text = _DetailModal.title;
_DescriptionLabel.text = _DetailModal.desc;
_ImageView.image = [UIImage imageNamed:_DetailModal.image];
_phoneTextView.text = @"(+34) 914 458 351";
_adressTextView.text = @"\n• Calle Manuela Malasaña, 10, Madrid, España";
}
if ([_DetailModal.title isEqualToString:@"90 Grados"]) {
_headerImage.image = [UIImage imageNamed:@"90_grados_head.jpg"];
_TitleLabel.text = _DetailModal.title;
_DescriptionLabel.text = _DetailModal.desc;
_ImageView.image = [UIImage imageNamed:_DetailModal.image];
_phoneTextView.text = @"(+34) 91 573 28 21";
_adressTextView.text = @"\n• Calle del Alcalde Sainz de Baranda, 64, Madrid, España";
}
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
// Return the number of rows in the section.
return [cellsIdentifier count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
NSString *cellIdentifier = [cellsIdentifier objectAtIndex:indexPath.row];
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier forIndexPath:indexPath];
// Configure the cell...
cell.phoneDetTextView.text = _phoneTextView.text;
return cell;
}
@end
这是我的RestDetailsTableViewCell.h:
#import <UIKit/UIKit.h>
@interface RestDetailsTableViewCell : UITableViewCell
@property (weak, nonatomic) IBOutlet UITextView *phoneDetTextView;
@end
这是我的Main.storyboard:
我是从Xcode开始的,我知道我的水平较低,但我每天都在努力提高。非常感谢您的回复!