xamarin ios 入门.ios无法存档出版问题,怎么解决

关注技术,不断学习中~~~
Xamarin IOS无法编译的时候报Xamarin.iOS.Common.targets error,但无其他错误提示
编译时报错:Xamarin.iOS.Common.targets(93,3):
没有其他任何提示信息
检查工程属性:
IOS Application:Deployment Target,发现是个默认值,将其改为9.1,保存,问题解决。
没有更多推荐了,
加入CSDN,享受更精准的内容推荐,与500万程序员共同成长!Xamarin.iOS — Xamarin Community Forums
Xamarin Inc.Xamarin iOS教程之页面控件
Xamarin iOS教程之页面控件
Xamarin iOS 页面控件
在iPhone手机的主界面中,经常会看到一排小白点,那就是页面控件,如图2.44所示。它是由小白点和滚动视图组成,可以用来控制翻页。在滚动滚动视图时可通过页面控件中的小白点来观察当前页面的位置,也可通过点击页面控件中的小白点来滚动到指定的页面。
图2.44 页面控件
在此图中,小白点对应的当前页被高亮显示。此控件指示内容分为两个页面。
【示例2-26】以下将使用页面视图来控制图像的显示。具体步骤如下:
(1)创建一个Single View Application类型的工程,命名为2-11。
(2)添加图像1.jpg、2.jpg、3.jpg到创建工程的Resources文件夹中。
(3)打开2-11ViewController.cs文件,编写代码,实现在使用滚动视图来控件图像的显示。代码如下:
using System.D
using MonoTouch.F
using MonoTouch.UIK
namespace Application
public partial class __11ViewController : UIViewController
UIImageView page1;
UIImageView page2;
UIImageView page3;
UIScrollView scrollV
UIPageControl pageC
&& //这里省略了视图控制器的构造方法和析构方法
#region View lifecycle
public override void ViewDidLoad ()
base.ViewDidLoad ();
// Perform any additional setup after loading the view, typically from a nib.
//添加滚动视图对象scrollView
scrollView = new UIScrollView ();
scrollView.Frame = new RectangleF (0, 0, 320, 495);
//滚动视图结束滚动时所调用的方法
scrollView.DecelerationEnded += this.scrollView_DecelerationE
//添加页面
pageControl = new UIPageControl ();
pageControl.Frame = new RectangleF (0, 540, 320, 37);
pageControl.Pages = 3; //设置页面控件的页数,即小白点
//当页面控件的数值发生改变时调用
pageControl.ValueChanged += this.pageControl_ValueC
//滚动视图的滚动事件
scrollView.Scrolled += delegate {
Console.WriteLine (&Scrolled!&);
scrollView.PagingEnabled =
RectangleF pageFrame = scrollView.F
scrollView.ContentSize = new SizeF (pageFrame.Width * 3, pageFrame.Height);
//添加图像视图对象page1
page1 = new UIImageView (pageFrame);
page1.ContentMode = UIViewContentMode.ScaleAspectF
page1.Image = UIImage.FromFile (&1.jpg&);
pageFrame.X += this.scrollView.Frame.W
//添加图像视图对象page2
page2 = new UIImageView (pageFrame);
page2.ContentMode = UIViewContentMode.ScaleAspectF
page2.Image = UIImage.FromFile (&2.jpg&);
pageFrame.X += this.scrollView.Frame.W
//添加图像视图对象page3
page3 = new UIImageView (pageFrame);
page3.ContentMode = UIViewContentMode.ScaleAspectF
page3.Image = UIImage.FromFile (&3.jpg&);
scrollView.AddSubview (page1);
scrollView.AddSubview (page2);
scrollView.AddSubview (page3);
this.View.AddSubview (scrollView);
this.View.AddSubview (pageControl);
private void scrollView_DecelerationEnded (object sender, EventArgs e)
float x1 = this.page1.Frame.X; //获取图像视图对象page1的x位置
float x2 = this.page2.Frame.X; //获取图像视图对象page2的x位置
float x = this.scrollView.ContentOffset.X; //获取滚动视图对象scrollView目前滚动的x位置
//判断x是否和x1相等
if (x == x1)
this.pageControl.CurrentPage = 0; //设置页面控件当前的页
} else if (x == x2) //判断x是否和x2相等
this.pageControl.CurrentPage = 1;
this.pageControl.CurrentPage = 2;
private void pageControl_ValueChanged (object sender, EventArgs e)
PointF contentOffset = this.scrollView.ContentO
//使用switch语句判断当前的页数
switch (this.pageControl.CurrentPage)
contentOffset.X = this.page1.Frame.X;
this.scrollView.SetContentOffset (contentOffset, true); //设置滚动视图目前滚动的位置
contentOffset.X = this.page2.Frame.X;
this.scrollView.SetContentOffset (contentOffset, true);
contentOffset.X = this.page3.Frame.X;
this.scrollView.SetContentOffset (contentOffset, true);
&& //这里省略了视图加载和卸载前后的一些方法
#endregion
运行效果如图2.45所示。
图2.45 运行效果
在页面控件中,需要开发者需要注意以下2个问题:
1.页面控件的属性设置
页面控件属性设置并不多,一般就是设置页数以及当前页。设置页面控件的页数,需要使用Pages属性,其语法形式如下:
页面控件对象.Pages=页数;
其中,页数是一个整型数据。设置页面控件的当前页,需要使用CurrentPage属性,其语法形式如下:
页面控件对象.CurrentPage=当前页;
其中,当前页是一个整型数据。
2.页面控件的响应
页面控件的响应需要使用ValueChanged事件实现。示例2-26中的代码如下:
pageControl.ValueChanged += this.pageControl_ValueC
本文选自:Xamarin iOS开发实战大学霸内部资料,转载请注明出处,尊重技术尊重IT人!Xamarin iOS开发实战上册 (内部资料)
[问题点数:20分]
本版专家分:10
结帖率 50%
CSDN今日推荐
本版专家分:0
本版专家分:10
结帖率 50%
本版专家分:0
本版专家分:0
2017年11月 .NET技术大版内专家分月排行榜第二2017年10月 .NET技术大版内专家分月排行榜第二
2018年6月 .NET技术大版内专家分月排行榜第三2018年3月 .NET技术大版内专家分月排行榜第三2017年12月 .NET技术大版内专家分月排行榜第三2017年9月 .NET技术大版内专家分月排行榜第三
本版专家分:0
本版专家分:0
本版专家分:0
匿名用户不能发表回复!|
CSDN今日推荐Xamarin.ios 绑定Objective-C libraries中容易出现的问题
This blog post is about producing better bindings of Objective-C libraries for and
. Read the series
get a better idea why this is important and how it can save you time and headaches.
What can go wrong ?
Binding a selector using a correct [Export("")] attribute
is only half the job. The .NET method signature must match the one defined in Objective-C. Xamarin.iOS does some magic, like converting string and NSString ,
but you still need to be careful. The most common mistakes are:
signed/unsigned types : this is often minor and you might want to
on some (or even all) of them.
means .NET developers prefer signed over unsigned integers (except for byte ).
Apple APIs often use unsigned integers when a number cannot be negative. For example:@property (nonatomic, readwrite) NSUInteger
[Export ("loops")]
int Loops { get; set; }
wrong types : a common case is a missing ref when
the Objective-C API requires a pointer to a value, not the value itself. For example:-(void) sphericalRadius:(float*) r zenith:(float*) zenith azimuth:(float*)
[Export ("sphericalRadius:zenith:azimuth:")]
void GetSphere (float radius, float zenith, float azimuth);
wrong size : this often happens on structures, but it can also occurs when a type name is misleading (e.g. long is
32 bits in Objective-C, at least for 32bits archs like i386 and ARM, while it is 64 bits on .NET) or when common usage differs, as in this case:-() :(ccTime)duration :(GLshort)deltaRed :(GLshort)deltaGreen :(GLshort)deltaBlue;
[Export ("initWithDuration:red:green:blue:")]
IntPtr Constructor (float duration, byte red, byte green, byte blue);
What can we check for ?
Quite a lot. It’s possible to get an encoded signature for selectors. The earlierloops selector,
for example, would return the “ I8@0:4 ”
string value.
From it we can extract the return value ( I an unsigned
int ) and all the parameters, e.g. self ( @ )
and the selector ( : ) are always
present and there are no other parameters since it’s a getter. We also get the size of the parameters, which can be compared to the size of the managed types used—and they should alwaysmatch!
Using all of the above, we can test pretty closely if an Objective-C signature matches the defined .NET signature. Simple? Not quite.
Objective-C encoding for structures is quite detailed. However, their internal names won’t match the one being used in your bindings. You’ll need to help the
map them by
its IsValidStruct method.
Why is this important ?
Signature mistakes are dangerous. Some APIs might (appear to) work, others will crash immediately (bad) or the crash will occur later (worse) because they will mess up the stack and cause memory corruption. Debugging such issues can be very time consuming,
so your time is well invested in using this fixture.
How to fix issues ?
Fixing the .NET signature to match it’s Objectice-C peer is the most common case. The failure will tell you which parameter (or the return value) looks wrong. You have to confirm/fix this using the library’s documentation and/or it’s header files.
One notable (and uncommon) exception is the use of a variable number of arguments (e.g. var_list in
Objective-C, params in C#).
They are not part of the encoded signature, so once confirmed you can skip them by
theSkip(Type,MethodInfo,string) method.
As discussed earlier, you might also want to override Check(char,Type) to
skip the signed/unsigned differences for integer types.
What’s missing ?
The encoded signature is not perfect. All NSObject parameters
are encoded as ‘@ ‘ so we cannot
detect if an NSData should have
been used instead of NSDate .
Since all objects are pointers, they all will be the same size ( IntPtr.Size )
so this will also not be noticed by the size check. Typos/errors, even if less common, are still possible.
This blog post concludes the five-part series on building better bindings for Xamarin.iOS and Xamarin.Mac. Thanks for reading!
原文链接:
没有更多推荐了,
加入CSDN,享受更精准的内容推荐,与500万程序员共同成长!

我要回帖

更多关于 xamarin ios 模拟器 的文章

 

随机推荐