AirPrint 和 NSMutableString
我有点卡住了:-)
我有一个小应用程序,它允许我将地址簿中的字段放入标签类型 UIView 中。现在我希望能够打印这些标签:-) 在这个阶段,我不介意它是否出现在一张普通的纸上——我稍后会整理出这部分。
我的问题是 - 我不知道如何打印从地址簿中提取的文本。
示例:
名字: -------- |这变成|名字:Joe Bloggs(来自地址簿)
现在是包含姓名、家庭、年龄的部分和数字 - 这是我要打印的部分。
有什么帮助吗?请???
PS我已经开始编写代码来解决这个问题,所以我不会把这个给你空白。我刚刚得到了相当多的代码:-) 所以我不确定要发布哪一点。
导致错误的位是这样的:
NSMutableString *printBody = [NSMutableString stringWithFormat:@"%@, %@",self.encoded.text, self.decoded.text];
干杯 ——杰夫
I am a little stuck:-)
I have a small app which allows me to put in fields from the address book into a label type UIView. Now I wish to be able to print those labels out:-)
I do not mind at this stage if it goes onto a normal piece of paper - I will sort that part out later.
My Questions is - I cannot figure out how to print text that I draw out from the addressbook.
EXAMPLE:
First Name: -------- | This become | First Name: Joe Bloggs (from the address book)
Now the section that has the name, household, age and number - That is the section I want to print out.
Any Help?? Please???
PS I have start to code my way through this, so I am not giving this to you blank. I just got a fair bit of code:-) So I am not sure which bit to post.
The bit that causes the error is this:
NSMutableString *printBody = [NSMutableString stringWithFormat:@"%@, %@",self.encoded.text, self.decoded.text];
Cheers
--Jeff
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您的错误:
在“printViewController *”类型的对象上找不到属性“encoded”
似乎表明您尚未将encoded声明为属性。为了使用您正在使用的点表示法,您必须将encoded
和decoded
声明为属性。我假设编码属于
UILabel
类,因为这就是屏幕截图中的样子。如果我对它的类的假设是正确的,你需要将它声明为一个属性,如下所示。在您的
printViewController.h
文件中,您应该有:在您的
.m
文件中,您应该有:或者一些手动编写的访问器。
您需要将标签本身连接到视图控制器上的 IBOutlet,您可以从界面生成器中执行此操作。
如果我误解了您的布局,请发表评论。
Your error :
property 'encoded' not found on object of type 'printViewController *'
seems to indicate that you have not declared encoded as a property. In order to use the dot notation you are using you will have to declareencoded
anddecoded
as properties.I'm going to assume that encoded is of class
UILabel
, since that is what it looks like in your screenshot. If my assumption about it's class is correct you need to declare it as a property like so.In your
printViewController.h
file you should have:And in your
.m
file you should have:Or some manually written accessors.
You will need to connect the label itself to your IBOutlet on the view controller which you can do from interface builder.
If I have misunderstood your layout leave a comment.