我有一个由UITableView
控制的NSFetchedResultsController
。我想将单个单元格添加到第一行并使该单元格保持静态。换句话说,将有一个按钮可以打开另一个视图控制器。
到现在为止,我对获取的结果控制器和表格感到满意。现在我有点困惑。我该怎么做?
相反,使用标题也可以,但我不希望此标题始终位于顶部。我希望这个单元格与聊天面板上的WhatsApp
iOS“Create new group
”单元格一样。
谢谢!
答案 0 :(得分:0)
您需要创建包含从NSFetchedResultsController +1获取的行数的tableview。同样在 UIGraphicsBeginImageContext(self.drawSignView.bounds.size);
[[self.drawSignView.layer presentationLayer] renderInContext:UIGraphicsGetCurrentContext()];
UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
// NSData *postData = UIImageJPEGRepresentation(viewImage, 1.0);
NSData *imgData = [[NSData alloc] initWithData:UIImageJPEGRepresentation((viewImage), 0.5)];
int imageSize = imgData.length;
NSLog(@"size of image in KB: %d ", imageSize/1024);
UIGraphicsBeginImageContext(self.drawSignViewClient.bounds.size);
[[self.drawSignViewClient.layer presentationLayer] renderInContext:UIGraphicsGetCurrentContext()];
UIImage *viewImageClient = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
// NSData *postData = UIImageJPEGRepresentation(viewImage, 1.0);
NSData *imgDataClient = [[NSData alloc] initWithData:UIImageJPEGRepresentation((viewImageClient), 0.5)];
int imageSizeClient = imgDataClient.length;
NSLog(@"size of image in KB: %d ", imageSizeClient/1024);
int OCS=imageSize/1024;
int Client=imageSizeClient/1024;
if(OCS<3)
{
alertviewshow=[[UIAlertView alloc] initWithTitle:@"Warning!" message:@"Please do Signature " delegate:self cancelButtonTitle:nil otherButtonTitles:@"OK", nil];
[alertviewshow setTag:1];
[alertviewshow show];
}
else if (Client<3)
{
alertviewshow=[[UIAlertView alloc] initWithTitle:@"Warning!" message:@"Please do Signature " delegate:self cancelButtonTitle:nil otherButtonTitles:@"OK", nil];
[alertviewshow setTag:1];
[alertviewshow show];
}
else
{
//Write Your Code....
}
方法中,您需要添加cellForRowIndex
之类的支票,然后您将进行更改。
此外,您还必须在该部分中为该按钮添加操作。您还可以为第一行设置不同的自定义indexPath.row == 0
。
它可以类似于以下内容:
tableview
答案 1 :(得分:0)
var dataArray = ["A","B","C"]
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return self.dataArray.count+1
}
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell
{
if indexPath.row == 0
{
let cell = tableView.dequeueReusableCell(withIdentifier: "CreateNewGroupCell") as! CreateNewGroupCell
return cell
}
else
{
// Get the data from Array
let data = self.dataArray[indexPath.row-1]
// Logic to show other cells
let cell = tableView.dequeueReusableCell(withIdentifier: "OtherCell") as! OtherCell
return cell
// ....
}
}