拥有Objective c基类:
@interface ObjcClass : NSObject {
NSString *aVariable_;
}
Run Code Online (Sandbox Code Playgroud)
一个迅速的子类:
class SwiftClass : ObjcClass {
func init() {
// aVariable_ can't be accessed here. An Objective-c derived
// class has direct access to it's super's instance variables!
}
}
Run Code Online (Sandbox Code Playgroud)
我如何ObjcClass
aVariable_
从内部访问SwiftClass
?
我如何声明这样的变量?
var rData = from nc in ctx.NEWSLETTER_CLIENTS
join ni in ctx.NEWSLETTER_INDICES on nc.INDEX_NUM
equals ni.INDEX_NUM
select new
{
ClientID = nc.CLIENT_ID,
Email = nc.CLIENT_EMAIL_ADDRESS,
Index = nc.INDEX_NUM,
MainClass = ni.MAIN_CLASS,
SubClass = ni.SUB_CLASS,
App1 = ni.VALUE_1,
App2 = ni.VALUE_2,
App3 = ni.VALUE_3,
App4 = ni.VALUE_4
};
// Now I need to declare on a variable named fData under the function scope,
// so I can later use it:
var fData = ...; //What do I declare here?
if(x)
fData …
Run Code Online (Sandbox Code Playgroud) Thread myThread = new Thread(new ParameterizedThreadStart(threadFunction));
public void threadFunction() {
// Run a finite code
...
}
Run Code Online (Sandbox Code Playgroud)
问题是:myThread
一旦threadFunction()
结束将被处置?
在简单的UIView上应用旋转变换后
CGAffineTransform trans = CGAffineTransformMakeRotation(M_PI * -0.5);
simpleVIew_.transform = trans;
Run Code Online (Sandbox Code Playgroud)
其中有以下约束
[self addConstraints:@[
[NSLayoutConstraint constraintWithItem: simpleView_ attribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationEqual
toItem:nil attribute:NSLayoutAttributeNotAnAttribute
multiplier:1 constant:50],
[NSLayoutConstraint constraintWithItem: simpleView_ attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual
toItem:self attribute:NSLayoutAttributeHeight
multiplier:1 constant:270],
[NSLayoutConstraint constraintWithItem: simpleView_ attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual
toItem:self attribute:NSLayoutAttributeLeft
multiplier:1.0 constant:0],
[NSLayoutConstraint constraintWithItem: simpleView_ attribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual
toItem:self attribute:NSLayoutAttributeBottom
multiplier:1.0 constant:0]
]];
Run Code Online (Sandbox Code Playgroud)
我在iOS7.1和iOS8 beta 5之间得到了两个不同的结果:
iOS7.1
<UIView: 0x1655d990; frame = (0 30; 50 270); transform = [0, -1, 1, 0, 0, 0]; opaque = NO; layer = <CALayer: 0x1655dab0>
Run Code Online (Sandbox Code Playgroud)
iOS8测试版5
<UIView: 0x16e5a530; …
Run Code Online (Sandbox Code Playgroud) 我可能会犯这个错误.所以我创建了一个UITableView,它基本上有一个自动布局尾随空间设置为主视图.我正在为这个表创建一个自定义单元格,所以我在原型单元格上进行定制,定制它,并为它创建我的类.这一切都很好.
我似乎无法解决的是自定义单元格不是实际表格单元格的整个宽度,因此只显示白色背景.如果我不使用自定义单元格,则可以使用整个宽度表单元格.
我为单元格内容设置了约束,以便背景图像填充单元格.
我究竟做错了什么?让我知道您需要帮助解决这个问题.
ProfileCustomCell.h
#import <UIKit/UIKit.h>
@interface ProfileCustomCell : UITableViewCell {
}
@property (nonatomic, strong) IBOutlet UILabel *nameLabel;
@property (nonatomic, strong) IBOutlet UIImageView *profileImageView;
@end
Run Code Online (Sandbox Code Playgroud)
ProfileCustomCell.m
#import "ProfileCustomCell.h"
@implementation ProfileCustomCell
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
if (self) {
self.nameLabel.text = nil;
}
return self;
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
[super setSelected:selected animated:animated];
}
@end
Run Code Online (Sandbox Code Playgroud)
UITableView的
[tableView registerNib:[UINib nibWithNibName:@"ProfileCustomCell" bundle:[NSBundle mainBundle]] forCellReuseIdentifier:@"Cell"];
[tableView setSeparatorStyle:UITableViewCellSeparatorStyleNone];
ProfileCustomCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
cell.nameLabel.text = [NSString stringWithFormat:@"%@", [child objectForKey:@"first_name"]]; …
Run Code Online (Sandbox Code Playgroud) 我正在尝试向打印机发送一个简单的字符串("Hello world"),但由于某种原因,它只打印第一个字符("H")
这是代码
public class CardPrinter {
public static void main(String[] args) {
try {
PrintService mPrinter = null;
Boolean bFoundPrinter = false;
PrintService[] printServices = PrinterJob.lookupPrintServices();
//
// Iterates the print services and print out its name.
//
for (PrintService printService : printServices) {
String sPrinterName = printService.getName();
if (sPrinterName.equals("DTC4000 Card Printer")) {
mPrinter = printService;
bFoundPrinter = true;
}
}
// Open the image file
String testData = "Hello World !";
InputStream is = new ByteArrayInputStream(testData.getBytes());
DocFlavor flavor …
Run Code Online (Sandbox Code Playgroud) 我有一个PDF文件,想在客户端桌面上打开它(所以我不知道他的默认PDF阅读器的目录)...
...
File.WriteAllBytes(pdfByteArray, path);
File.Open(path, FileMode.Open);
...
Run Code Online (Sandbox Code Playgroud)
似乎不在这里工作......
我有一个 Winform C# 中的应用程序。我需要保存用户在表单控件(例如文本框、日期时间选择器等)中输入的值。
这样做最好的办法是什么?再次启动程序时将读取这些内容。我还需要将值保存在一个数据网格中,该数据网格可能只有大约 20 行。
任何帮助/指示将不胜感激。
我有以下情况,我想问一下什么是最好的解决方案?
我有一个特定的文件我想要特定用户(根据一些权限)下载此文件.
所以我只为授权用户显示此文件,但如果有人(未经授权)识别文件链接(知道链接url
)并下载它会怎样!
如何只允许下载此文件authorized users
.
我已经尝试到了什么:
呼唤 measure()
tv.measure(0, 0);
int height = tv.getMeasuredHeight();
Run Code Online (Sandbox Code Playgroud)measure()
以指定的尺寸/模式进行呼叫
int widthMeasureSpec = View.MeasureSpec.makeMeasureSpec(99999, View.MeasureSpec.AT_MOST);
int heightMeasureSpec = View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED);
tv.measure(widthMeasureSpec, heightMeasureSpec);
int height = tv.getMeasuredHeight();
Run Code Online (Sandbox Code Playgroud)呼唤 getTextBounds()
Rect bounds = new Rect();
tv.getPaint().getTextBounds(tv.getText().toString(), 0, tv.getText().length(), bounds);
int height = bounds.height();
Run Code Online (Sandbox Code Playgroud)先打电话measure()
再打电话getTextBounds()
getLineCount() * getLineHeight()
似乎没有任何工作。它们都返回不正确的值(容器视图的高度不正确-太小或太大)
关于如何计算这个简单事情的想法?
c# ×5
ios ×3
objective-c ×3
java ×2
android ×1
asp.net ×1
autolayout ×1
iis ×1
ios8 ×1
iqueryable ×1
linq ×1
printing ×1
security ×1
swift ×1
textview ×1
uitableview ×1
winforms ×1