我正在尝试UILabel根据标签中的文本数量来更改a的高度.
我可以计算标签所需的尺寸,但是当我尝试设置UILabel框架时它就不会改变.
以下是我的代码.即使我将最后一行中的size.height替换为类似于500的大小,UILabel帧的大小也不会改变
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *simpleTableIdentifier = @"GameItemCell";
GameItemCell *cell = (GameItemCell *)[tableView dequeueReusableCellWithIdentifier:simpleTableIdentifier];
NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"GameItemCell" owner:self options:nil];
cell = [nib objectAtIndex:0];
GameItem* item = [_hunt.gameItems objectAtIndex: indexPath.row];
cell.itemHeaderLabel.text = [NSString stringWithFormat:@"#%d - (%d pts)", indexPath.row+1, item.itemPoints];
UILabel* textLabel = cell.itemTextLabel;
textLabel.text = item.itemText;
textLabel.lineBreakMode = NSLineBreakByWordWrapping;
CGRect frame = cell.itemTextLabel.frame;
CGSize textSize = { frame.size.width, 20000.0f };
CGSize sizeOneLine = [@"one line" …Run Code Online (Sandbox Code Playgroud) 出于某种原因,我无法使用post方法将jpeg文件上传到服务器 NSURLRequest
我有一个Android应用程序使用相同的PHP代码,可以通过将图像转换为字节数组,然后使用base64编码发送和接收上传和下载图像.
我的iPhone应用程序下载图像正常,php脚本使用base64进行编码,我在我的iPhone应用程序中使用base64解码器,然后我将其转换为图像.这很好用.
但是,上传图像不起作用.
我将图像转换为base64编码的字符串(我使用了几种不同的base64编码方法,它们都给出相同的结果)然后我发布到服务器,在服务器端解码并保存到服务器上的文件.
服务器上生成的解码文件是损坏的jpeg图像.损坏的文件大小是应有的字节数的3倍.
为上载生成的base64编码字符串也与从服务器下载相同jpeg文件时生成的base64编码字符串(即我使用ftp服务上传的有效映像文件)非常不同.
下面显示了我的代码以及用于接收图像的php脚本.
我相信转义字符会发生一些事情,导致base64字符串在传输过程中被破坏但无法解决.
为什么我的base64字符串在传输过程中被破坏了?
NSString* comments = @"comments to go with image";
NSData *data = UIImageJPEGRepresentation(_imageView.image, 1);
NSString *base64EncodedImage = [NSString base64StringFromData: data length: data.length];
//load the team posts so we know what items have been posted and what haven't
NSMutableDictionary *postDict = [NSMutableDictionary dictionaryWithObjectsAndKeys:
comments, @"comment",
base64EncodedImage , @"image",
nil];
NSMutableArray *parts = [[NSMutableArray …Run Code Online (Sandbox Code Playgroud)