我需要创建一个简单的聊天视图,在其中我可以像任何消息应用程序一样显示来自两端(发送者和接收者)的消息.
到目前为止,我所做的是创造一个UITableView,A UIButton和一个UITextField.在UIButton上,我将UITextField文本添加到数组中,现在我需要第二个端点,就像我们的Messaging应用程序(发送方)一样.
左侧是接收器,右侧是发送器.
我的应用程序到现在为止
这是我的代码:
- (UITableViewCell *)tableView:(UITableView *)tableView
cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
messageLabel = nil;
UITableViewCell *cell = [tableView
dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
messageLabel = [[UILabel alloc] init];
messageLabel.tag = 101;
[cell.contentView addSubview: messageLabel];
} else {
messageLabel = (UILabel*)[cell.contentView viewWithTag: 101];
} //---calculate the height for the label---
int labelHeight = [self labelHeight:[listOfMessages objectAtIndex:indexPath.row]];
labelHeight -= bubbleFragment_height;
if (labelHeight<0) labelHeight = …Run Code Online (Sandbox Code Playgroud) 我需要设置这样的格式: 7 Aug 2015 14:42:11
这是我的代码:
NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
formatter.dateFormat = @"yyyy-MM-dd HH:mm:ss";
NSString *string = [formatter stringFromDate:[NSDate date]];
NSLog(@"Date Current :- %@",string);
Run Code Online (Sandbox Code Playgroud) 我想将我的UIButton标题设置为=== Don`t有一个帐户?注册
如何使一些文字大胆.
UIButton *signUpButton = [[UIButton alloc]initWithFrame:CGRectMake(40, 270, 240, 40)];
[signUpButton setTitle:@"Don`t have an account? Sign Up" forState:UIControlStateNormal];
[signUpButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
signUpButton.titleLabel.font = [UIFont systemFontOfSize:14];
[signUpButton setBackgroundColor:[UIColor clearColor]];
[signUpButton addTarget:self action:@selector(signUpAction) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:signUpButton];
Run Code Online (Sandbox Code Playgroud)
无法实现属性字符串..