这是这个问题的副本.我再次问,因为接受的答案不起作用,没有人提供更多关于假设正确答案是如何工作的解释.
所以情况就是这样:我想将集合视图显示在一行中.为此,我将自定义应用于UICollectionViewFlowLayout
集合视图并将滚动设置为水平.一切都工作正常,除了节头消失了.
为了解决这个问题,我实现了这个功能:
- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout referenceSizeForHeaderInSection:(NSInteger)section
{
return CGSizeMake(350, 35);
}
Run Code Online (Sandbox Code Playgroud)
现在显示标题,但问题是它显示在单元格的左侧,而不是通常的顶部.
我在寻找解决方案时偶然发现了上面的链接,但就像我说的那样,接受的答案根本不起作用,我无法找到关于这种情况的其他解决方案.所以有人可以帮助我吗?
我知道这个问题必须经过很多次回答,但现在真的让我头疼.
该touchesBegan:
不会被调用在我UIView.在我在我的应用程序中添加它之前,我先做了一个试验项目.在试验项目中,一切都很完美.我所做的touchesBegan:
是将正在实现的UIView子类化,并将此UIView添加为另一个视图的子视图.第二个视图有一个按钮,显示单击后的子类UIView.同样,一切都完全符合我的要求.
现在,当我在现有应用程序中执行相同操作时,从不调用touchesBegan:
方法(以及touchesMoved:
).任何人都可以向我解释原因吗?我只是不明白为什么它从未被调用过.
在我MainViewController
,我通过这个提出另一个视图控制器:
MessageViewController *messageController = [[MessageViewController alloc]initWithNibName:nil bundle:nil];
[messageController setModalPresentationStyle:UIModalPresentationFullScreen];
[messageController setModalTransitionStyle:UIModalTransitionStyleFlipHorizontal];
[self presentViewController:messageController animated:YES completion:nil];
[messageController release];
Run Code Online (Sandbox Code Playgroud)
这将正确显示视图控制器.但是,当我尝试返回到呈现视图控制器时,在这种情况下应该是MainViewController
,这段代码不起作用:
if ([self.presentingViewController isKindOfClass:[MainViewController class]])
[(MainViewController *)self.presentingViewController setCurrentViewTag:2];
[self dismissModalViewControllerAnimated:YES];
Run Code Online (Sandbox Code Playgroud)
我删除了"if .."条件以强制它设置当前视图标记.发生错误告诉我呈现视图控制器似乎是UINavigationController
:
[UINavigationController setCurrentViewTag:]: unrecognized selector sent to instance 0x8352a50
Run Code Online (Sandbox Code Playgroud)
谁能告诉我为什么会这样?这段代码之前曾经工作过,我不确定是什么改变了它使它停止正常工作.
编辑
这是更新的代码:
ReaderController *readerController = [[ReaderController alloc]initWithNibName:nil bundle:nil];
[readerController loadWhichViewToShow:2];
[self setDefinesPresentationContext:YES];
[readerController setModalPresentationStyle:UIModalPresentationFullScreen];
[readerController setModalTransitionStyle:UIModalTransitionStyleFlipHorizontal];
[self presentViewController:readerController animated:YES completion:nil];
[readerController release];
Run Code Online (Sandbox Code Playgroud) 我有一个从我们的应用程序创建的框架,当该框架添加到要使用的新项目时,它运行得很好。
现在我们想要添加不同语言的本地化,我们在应用程序中做到了这一点,一切都运行良好,但现在我们想要更新我们的框架以使用多种语言进行本地化。因此,我们在框架内添加了所有本地化的 xib 及其字符串,但框架中的 nib 文件始终只显示英语。
我不太熟悉框架,因为它是由其他人完成的,我们只是遵循如何更改文件并创建更新的框架。
我一直在尝试在互联网上查找一些信息,但我发现的只是如何更改代码中的 UILabel,而不是通过本地化 nib 文件。
有什么建议么?
我想在调用touchesMoved时存储点数.到目前为止一切正常.但是,我想要做的是每次调用touchesMoved时创建一个"new"数组.例如,一旦触摸结束,点阵列就会被保存到标识符为1的数据库中.下次调用touchesMoved时,阵列将被清空并替换为另一组具有不同标识符的点.我尝试在每次调用touchesEnded时递增一个整数,但我发现每次触摸结束时整数都会保持不变.那我该怎么做呢?任何帮助将非常感谢.
更新:例如我在我的数组中有这些记录点:
100.000, 200.000
100.000, 202.000
100.000, 204.000
Run Code Online (Sandbox Code Playgroud)
这些点将使用标识符保存在数据库中,假设为1.
1 | 100.000 | 200.000
1 | 100.000 | 202.000
1 | 100.000 | 204.000
Run Code Online (Sandbox Code Playgroud)
现在,当触摸移动并再次结束时,新的记录点集将以不同的标识符保存,比方说2.
2 | 200.000 | 300.000
2 | 200.000 | 302.000
2 | 200.000 | 304.000
Run Code Online (Sandbox Code Playgroud)
基本上我想要发生的是每次调用touchesMoved时,它都会记录将保存在数组中的点.当触摸结束时,这些记录的点将与标识符一起保存.AND,一旦再次调用touchesMoved并结束,新的记录点集将以不同的标识符保存.有什么想法怎么做?
我的任务是为我们公司创建一个pdf阅读器应用程序.经过一些研究后,我对PDF中的不同操作符感到困惑.以下是我想澄清的一些事项:
Tm
操作者被用作每行的开始点.(我的理解是否正确?)如果Tm
运算符是每一行的起点,我如何解析仅在指定范围内显示的文本Tm
?例如:
BT
0 0 1 rg
/Ti 12 Tf
1 0 0 1 100 100 Tm
0 0 Td
(The quick brown fox ) Tj 0 ?13 Td
(ate the lazy mouse.) Tj
ET
//I only want to get the Tj and TJ string being positioned by the Tm
Run Code Online (Sandbox Code Playgroud)据我所知,每1000字形的字形高度和宽度相当于1个单位的文本空间.因此,如果字形宽度为2000且高度为1060,那是否意味着它的"实际"宽度和高度分别为2和1.06?
现在我知道其中一些问题完全是愚蠢的,但我真的没有太多时间去研究.所以如果有人能帮助我理解这一点,那将是绝对值得赞赏的.
注意:pdf阅读器应用程序必须包含搜索和突出显示功能,文本选择,备注,书签等.实际上,您现在几乎所有阅读器中都可以找到所有基本内容.我可能会使用第三方库来使我的生活更轻松,但我最大的问题是文本选择功能.所以我真的需要了解这一点.
我有一个用于MFMailComposeViewController
通过电子邮件发送文件的应用程序.我在某处读到了我需要启用至少一封电子邮件,以便该方法[MFMailComposeViewController canSendEmail]
返回YES并通过电子邮件发送文档.但是,每当我点击电子邮件按钮时,它只会返回上一个视图.
我检查了代码并[MFMailComposeViewController canSendEmail]
返回NO.谁能告诉我为什么会这样?
这是代码:
- (void)sendEmail
{
if ([MFMailComposeViewController canSendMail] == NO) return;
NSURL *fileURL = document.fileURL; NSString *fileName = document.fileName;
NSData *attachment = [NSData dataWithContentsOfURL:fileURL options:(NSDataReadingMapped|NSDataReadingUncached) error:nil];
if (attachment != nil)
{
MFMailComposeViewController *mailComposer = [MFMailComposeViewController new];
[mailComposer addAttachmentData:attachment mimeType:@"application/pdf" fileName:fileName];
[mailComposer setSubject:fileName];
mailComposer.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
mailComposer.modalPresentationStyle = UIModalPresentationFormSheet;
mailComposer.mailComposeDelegate = self;
[self presentModalViewController:mailComposer animated:YES];
[mailComposer release];
}
}
Run Code Online (Sandbox Code Playgroud) ios ×6
objective-c ×2
cgpoint ×1
cocoa-touch ×1
localization ×1
mfmailcomposeviewcontroller ×1
pdf ×1
uiview ×1
xcode ×1