UITableview不滚动?(UITableview Not scrolling?)
我在
cellForRowAtIndex
方法中使用以下代码,但tableview
不滚动?static NSString *CellIdentifier = @"Cell"; UITableViewCell *cell = [tableView1 dequeueReusableCellWithIdentifier:CellIdentifier]; if (cell == nil) { cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier]; } cell.textLabel.adjustsFontSizeToFitWidth = YES; cell.textLabel.text = [NSString stringWithFormat:@"...%@...", hit.neighboringText]; return cell;
I am using following code in
cellForRowAtIndex
method, but thetableview
is not scrolling?static NSString *CellIdentifier = @"Cell"; UITableViewCell *cell = [tableView1 dequeueReusableCellWithIdentifier:CellIdentifier]; if (cell == nil) { cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier]; } cell.textLabel.adjustsFontSizeToFitWidth = YES; cell.textLabel.text = [NSString stringWithFormat:@"...%@...", hit.neighboringText]; return cell;
原文:https://stackoverflow.com/questions/16580902
最满意答案
由于您正在进行的唯一过滤是从
/var/www/html
下的名称中删除前导斜杠,因此您可以单独使用tar
- 避免find
的无数问题:tar -C / -czvf /root/archive-of-files-with-spaces-in-filename.tar.gz var/www/html
给定一个目录,
tar
备份目录的内容。 如果您在/var/html
下有子目录,那么您的存档可能是必要的两倍。 这个不会超过必要的。
显然,
find
命令包含选项。 在这种情况下,你必须以另一种方式做事:(cd /; find var/www/html -type f -mmin -1450 -print0) | tar -C / --null -T - --czvf /root/archive-of-files-with-spaces-in-filename.tar.gz
cd /; find var/html
cd /; find var/html
避免find
前导斜杠。-print0
对文件名使用空终止符。--null
告诉tar
期望文件名以null结尾;-T -
表示从标准输入读取文件名列表。如果您愿意,可以将所有内容放在一行中。 这不是我做的方式。 我将创建一个由
cron
(crontab
)系统运行的脚本,该脚本可以完成这项工作,特别是因为如果我运行它,输出文件名将不可避免地带有时间戳,并且它可能会识别哪个站点正在被支持要备份的站点将是脚本的参数,由crontab
条目提供。 这是我的偏好; 有很多人在crontab
文件中写入长行。此外,GNU
tar
(吵闹)省略了归档名称的前导斜杠,因此GNUtar
生成的tar
文件中绝不存在绝对名称:tar: Removing leading `/' from member names
这意味着您可以避免使用子shell,只需使用
find /var/www/html …
生成名称,并附带警告消息。 既然你有详细的输出,那不太可能是一个问题。Since the only filtering you're doing is to remove leading slashes from names under
/var/www/html
, you can usetar
alone — avoiding a myriad problems withfind
:tar -C / -czvf /root/archive-of-files-with-spaces-in-filename.tar.gz var/www/html
Given a directory,
tar
backs up the contents of the directory. If you have sub-directories under/var/html
, your archive was probably twice as big as necessary. This one won't be bigger than necessary.
Apparently, the
find
command includes options. In that case, you have to do things the other way:(cd /; find var/www/html -type f -mmin -1450 -print0) | tar -C / --null -T - --czvf /root/archive-of-files-with-spaces-in-filename.tar.gz
The
cd /; find var/html
avoids leading slashes fromfind
. The-print0
uses null terminators for the file names. The--null
tellstar
to expect file names to be null-terminated; the-T -
says read the list of file names from standard input.You can put all that on a single line if you wish. It isn't the way I'd do it. I would create a script that would be run by the
cron
(crontab
) system that would do the job, especially since the output file name would inevitably be time-stamped if I was running it, and it would probably identify which site was being backed up, etc. The site to be backed up would be a parameter to the script, supplied by thecrontab
entry. That's my preference; there are plenty of people who write long lines into theircrontab
files.Also, GNU
tar
(noisily) omits the leading slash from archive names, so that there are never absolute names inside atar
file generated by GNUtar
:tar: Removing leading `/' from member names
That means you could avoid the sub-shell and simply use
find /var/www/html …
to generate the names, living with the warning message. Since you have verbose output anyway, that's not likely to be much of a problem.
相关问答
更多-
LINUX 如何查看JPG文件[2022-06-13]
find -
那么,适合你的命令是 sudo tar -cvpzf backupfolder/localhost.tar.gz /var/www 这意味着,您必须使用sudo访问权限运行该命令,并且它将无法在您的crontab中运行。 我建议将cron作业添加到root用户的crontab中。 基本上,做 sudo crontab -e 并在那里添加一个条目 0 17 * * * cd /home/user/backupfolder && tar -cpzf localhost.tar.gz /var/www 如果这 ...
-
用这个: find . -type f -print0 | tar -czvf backup.tar.gz --null -T - 它会: 处理带有空格,换行符,引导破折号和其他功能的文件 处理无限数量的文件 不会重复覆盖你的backup.tar.gz,像使用tar -c与xargs会做,当你有大量的文件 另见: GNU tar手册 如何从stdin构建tar? ,搜索null Use this: find . -type f -print0 | tar -czvf backup.tar.gz --nul ...
-
PharData旨在用作Phar PHP应用程序归档格式的一部分 。 它不适用于一般用途。 使用Archive_Tar PEAR类创建tar存档。 PharData is meant to be used as part of the Phar PHP application archiving format. It's not intended for general use. Use the Archive_Tar PEAR class to create tar archives.
-
绝对没有区别。 文件名只是一个文件名。 通常 ,当你使用tgz格式时,它表明你已经压缩了tar文件(作为第二步或使用z标志): tar zcvf filename.tgz {filenames} 要么 tar cvf filename {filenames} gzip -S .tgz filename 另一方面, .tar通常表示“这是一个未压缩的 tar文件”: tar cvf filename.tar {filenames} 大多数现代tar实现也支持j标志使用bzip2压缩,所以你也可以使用: ...
-
如何将文件名传递给tar?(How can I pipe a filename to tar?)[2023-10-19]
假设您的文件名不包含任何空格/ glob字符,您可以这样做: ls file-* | tail -1 | xargs tar -xvf Assuming your filename don't contain any whitespace/glob characters you can do this: ls file-* | tail -1 | xargs tar -xvf -
您可以在命令之间添加双&&以强制第二个等待第一个。 例如, tar -zcf data_${machine}.tar.gz /tmp/data && echo "DONE" 此外,您可能不应该在后台运行tar命令(&) You can add a double && between commands to force the second to wait for the first. For example, tar -zcf data_${machine}.tar.gz /tmp/data && ech ...
-
要摆脱“tar:从成员名称中删除前导'/': 添加-C /并从路径中删除前导/ 。 tar -C / -zcvf /root/TEST1-strip-slash-find-statement.tar.gz `find /root/test -mmin -1450 -print | sed 's|^/||'` To get rid of "tar: Removing leading `/' from member names": Add -C / and remove leading / from your ...
-
由于您正在进行的唯一过滤是从/var/www/html下的名称中删除前导斜杠,因此您可以单独使用tar - 避免find的无数问题: tar -C / -czvf /root/archive-of-files-with-spaces-in-filename.tar.gz var/www/html 给定一个目录, tar备份目录的内容。 如果您在/var/html下有子目录,那么您的存档可能是必要的两倍。 这个不会超过必要的。 显然, find命令包含选项。 在这种情况下,你必须以另一种方式做事: (cd ...
-
正如mouviciel在评论中所说, tar默认在当前工作目录中创建文件。 只需在tar.gz文件前加上该文件夹的前缀,它就会在您想要的位置创建它: tar -czvf /tmp/psk1/hadoop_validation$ENV/${folder_name}.tar.gz /tmp/psk1/hadoop_validation$ENV/${folder_name} 请注意,因为您将在归档的同一文件夹中创建tar,所以file changed as we read it作为输出的一部分file chan ...