这是我的问题:UITableView我的故事板中有这么小:
这是我的代码:
SmallTableViewController.h
#import <UIKit/UIKit.h>
#import "SmallTable.h"
@interface SmallViewController : UIViewController
@property (weak, nonatomic) IBOutlet UITableView *myTable;
@end
Run Code Online (Sandbox Code Playgroud)
SmallTableViewController.m
#import "SmallViewController.h"
@interface SmallViewController ()
@end
@implementation SmallViewController
@synthesize myTable = _myTable;
- (void)viewDidLoad
{
SmallTable *myTableDelegate = [[SmallTable alloc] init];
[super viewDidLoad];
[self.myTable setDelegate:myTableDelegate];
[self.myTable setDataSource:myTableDelegate];
// Do any additional setup after loading the view, typically from a nib.
}
- (void)viewDidUnload
{
[super viewDidUnload];
// Release any retained subviews of the main view.
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{ …Run Code Online (Sandbox Code Playgroud) 我正在尝试用C编写UDP服务器(在Linux下).我知道在socket()函数中我必须使用SOCK_DGRAM而不是SOCK_STREAM.
if ( (list_s = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)) < 0 )
{
fprintf(stderr, "ERROR");
}
Run Code Online (Sandbox Code Playgroud)
但现在,当我尝试运行程序时(编译时没有错误),它表示存在错误listen().这是对它的调用:
if (listen(list_s, 5) < 0)
{
fprintf(stderr, "ERROR IN LISTEN");
exit(EXIT_FAILURE);
}
Run Code Online (Sandbox Code Playgroud)
你能弄明白问题是什么吗?这是代码:
int list_s; /* listening socket */
int conn_s; /* connection socket */
short int port; /* port number */
struct sockaddr_in servaddr; /* socket address structure */
if ( (list_s = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)) < 0 )
{
fprintf(stderr, "ERROR\n");
}
memset(&servaddr, 0, …Run Code Online (Sandbox Code Playgroud) 我正在为iOS 6开发一个App,这是我的观点之一.
现在我已将iPhone更新到iOS 7,结果如下:

现在所有的视图都在导航栏后面,因为iOS 7的UIViewController视图从屏幕的左上角开始,而不是在iOS 6的UINavigationBar下.现在,"email"字段位于导航栏后面.有没有办法使用iOS 6风格?
谢谢
马尔科
我已经创建了一个子类,UITableViewCell并且我调用了它DCCustomCell.这是DCCustomCell.h文件.
#import <UIKit/UIKit.h>
@interface DCCustomCell : UITableViewCell
@property (weak, nonatomic) IBOutlet UIImageView *imageView;
@property (weak, nonatomic) IBOutlet UILabel *title;
@property (weak, nonatomic) IBOutlet UILabel *date;
@property (weak, nonatomic) IBOutlet UILabel *price;
@end
Run Code Online (Sandbox Code Playgroud)
所有礼节都与我iPhone.storyboard文件中的元素正确连接.我还选择了tableViewCell,iPhone.storyboard并将我的单元格标识符设置为"CustomCell",并将类设置为DCCustomCell.
这是UITableViewController的viewDidLoad方法:
- (void)viewDidLoad
{
[super viewDidLoad];
self.tableView.delegate = self;
self.tableView.dataSource = self;
[self.tableView registerClass:[DCCustomCell class] forCellReuseIdentifier:@"CustomCell"];
// Do any additional setup after loading the view, typically from a nib.
}
Run Code Online (Sandbox Code Playgroud)
这是tableView:cellForRowAtIndexPath:方法:
-(UITableViewCell *)tableView:(UITableView …Run Code Online (Sandbox Code Playgroud) 我的UItableViewCell附件按钮有问题.我的配件按钮与另一个UIViewController的segue"连接".当我点击一个附件按钮时,我从模型中获取对象,并将此对象"传递"到segue destinationViewController.这是我对segue方法的准备:
-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
if ([segue.identifier isEqualToString:@"IdentityCard"])
{
NSLog(@"%i" ,self.tableView.indexPathForSelectedRow.row);
[segue.destinationViewController showIdentityCardForTeacher:[self.teachers getTeacherInPosition:self.tableView.indexPathForSelectedRow.row]];
}
}
Run Code Online (Sandbox Code Playgroud)
问题是方法开头的NSLog(在"if"之后)始终显示数字0!我试着实现这个方法:
-(void)tableView:(UITableView *)tableView accessoryButtonTappedForRowWithIndexPath:(NSIndexPath *)indexPath
Run Code Online (Sandbox Code Playgroud)
但是在这个方法之前执行了segue方法的准备,所以我不能设置任何@property来"保存"indexPath.我怎么解决这个问题?
我有这个故事板:

当我按下第一个视图控制器中的"Insegnante"按钮(它被称为newCourseViewController)时,它会显示一个带有教师列表的表格视图.当我按下一个老师(并tableView:canEditRowAtIndexPath:调用该方法)时,我希望将UITableViewController按下的对象"传递"到第一个视图控制器.
这是我的第一个视图控制器newCourseViewController.h的代码
#import <UIKit/UIKit.h>
#import "Teacher.h"
@interface newCourseViewController : UIViewController
@property (nonatomic , strong) Teacher *teacher;
@end
Run Code Online (Sandbox Code Playgroud)
这是我的第一个视图控制器newCourseViewController.m的代码(只有重要的代码)
#import "newCourseViewController.h"
#import "Courses.h"
#import "Teacher.h"
#import "addTeacherToCourseViewController.h"
@interface newCourseViewController ()
@property (weak, nonatomic) IBOutlet UITextField *textField;
@end
@implementation newCourseViewController
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view.
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
-(void)setTeacher:(Teacher …Run Code Online (Sandbox Code Playgroud) 我正在与代表进行一些练习,但现在我遇到了UIView的问题.这是我的故事板
我想用3个UISliders改变UIView的颜色.UISliders的范围是0到255.这是我的代码:
ColorField是UIView自定义类
ColorField.h
#import <UIKit/UIKit.h>
@protocol ColorFieldDelegate <NSObject>
-(NSArray *)giveMeColors;
@end
@interface ColorField : UIView
@property (nonatomic , weak) IBOutlet id<ColorFieldDelegate> delegate;
@end
Run Code Online (Sandbox Code Playgroud)
ColorField.m
#import "ColorField.h"
@implementation ColorField
@synthesize delegate = _delegate;
- (id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
// Initialization code
}
return self;
}
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect
{
// Drawing code
NSArray *arrayOfColors = [self.delegate giveMeColors];
int …Run Code Online (Sandbox Code Playgroud) 所以,这是我的观点:

这是我的UItableViewDelegate和DataSource
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 1;
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return 20;
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"course"];
cell.textLabel.text = [NSString stringWithFormat:@"%i" ,arc4random() % 10];
cell.detailTextLabel.text = [NSString stringWithFormat:@"%i" ,arc4random() % 10];
return cell;
}
Run Code Online (Sandbox Code Playgroud)
这就是结果:

问题是UItableView不滚动.决不.我真的无法弄清楚为什么......有人可以帮帮我吗?
uitableview ×5
objective-c ×4
ios ×3
iphone ×3
segue ×2
uiview ×2
background ×1
bind ×1
c ×1
delegates ×1
indexing ×1
ios7 ×1
listen ×1
parent-child ×1
rgb ×1
sockets ×1
storyboard ×1
subclass ×1
udp ×1
uitouch ×1