我试图从另一个模块(A)导入一个类.还有另一个模块是android app(B).所以我试图将A导入B
settings.gradle:
include ':A', ':B'
Run Code Online (Sandbox Code Playgroud)
B build.gradle :
dependencies {
compile project(':A')
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.1'
}
Run Code Online (Sandbox Code Playgroud)
当我尝试进行gradle同步时,它给了我以下错误:
错误:与依赖项'org.hamcrest:hamcrest-core'冲突.app(1.1)和测试app(1.3)的已解决版本有所不同.有关详细信息,请参阅 http://g.co/androidstudio/app-test-app-conflict.
错误:与依赖'junit:junit'冲突.app(4.8.2)和测试app(4.12)的已解决版本有所不同.有关详细信息,请参阅 http://g.co/androidstudio/app-test-app-conflict.
如果我删除该行:
compile project(':A')
Run Code Online (Sandbox Code Playgroud)
gradle同步没有任何错误,但我无法将A导入B.
有人可以告诉我为什么它会导致错误吗?
我有一个集合视图,显示应用程序中的时间段。在黑暗模式下,UILabel 似乎没有在白色背景上显示黑色文本颜色。
在故事板中,我已将标签的颜色设置为黑色(也尝试了默认颜色)。
在代码中,当用户选择单元格时,
func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
if let cell = collectionView.cellForItem(at: indexPath) as? TimeCell{
cell.timeLabel.toggleTheme(true)
}
}
Run Code Online (Sandbox Code Playgroud)
我有 UILabel 扩展:
extension UILabel{
func toggleTheme(_ selected : Bool){
if selected{
if #available(iOS 13.0, *) {
if self.traitCollection.userInterfaceStyle == .dark{
self.textColor = UIColor.black
self.backgroundColor = UIColor.white
}else{
self.textColor = UIColor.white
self.backgroundColor = UIColor.black
}
} else {
self.textColor = UIColor.white
self.backgroundColor = UIColor.black
}
}else{
if #available(iOS 13.0, *) {
if self.traitCollection.userInterfaceStyle == .dark{
self.textColor = …Run Code Online (Sandbox Code Playgroud) 对于两个我一直在努力解决以下问题:
我应该创建将要放置的消息聊天视图NSTableView.它必须有彩色背景,圆角,自定义边距.我试过NSTextField但没有成功.我有所需的背景和圆角,但文字显示不正确,因为它在多行的情况下从字段的中心开始.我也试过NSTextView,这似乎是在这种情况下更好的解决方案,但我无法设置圆角.我尝试过使用[textView.layer setCornerRadius:7.0];但没有效果.
谢谢你的回复!
我正在努力将搜索栏添加到现有应用中。
我有一个表格,其中填充了从服务器下载的数据,并且正在使用新的UISearchController。
我现在使搜索栏全部正常工作,并且随着用户在搜索栏中键入内容,将显示一个经过过滤的新结果表。
我的问题是如何处理用户从这个新的过滤后的搜索结果表中选择一个项目?
我从过滤后的表中添加了一个新的序列,并添加了didSelectRowAtIndexPath,它的工作原理很好-但是当用户从过滤后的表中选择一个项目时,搜索栏仍然存在,然后单击“取消”会使该应用程序崩溃。
因此,我不确定应该怎么做以及如何处理用户从过滤表中选择项目的问题?
我会保持事物的样子,但添加一些代码以在用户选择项目时取消搜索栏吗?
还是我做错了,有没有办法在用户选择过滤项时将选择从过滤表移回主ViewController表?
一如既往地非常感谢您的协助!
我试图了解方法调用方案的场景,确实/将会出现和消失.
我所做的是选择表格单元格(灰色高光),转到详细视图并返回并取消选择所选行(删除选定的单元格灰色).
这是我的方法:
-(void)viewDidAppear:(BOOL)animated {
DLog(@"%@ did appear", self);
[super viewDidAppear:animated];
if (_isPushed) {
[self.tableView deselectRowAtIndexPath:[self.tableView indexPathForSelectedRow] animated:YES];
_isPushed=NO;
}
}
-(void)viewWillAppear:(BOOL)animated {
DLog(@"%@ will appear", self);
[super viewWillAppear:animated]; //If I remove this super call , then it works fine and there is no delay in deselecting the table cell
}
-(void)viewWillDisappear:(BOOL)animated {
DLog(@"%@ will disappear", self);
[super viewWillDisappear:animated];
}
-(void)viewDidDisappear:(BOOL)animated {
[super viewDidDisappear:animated];
_isPushed=YES;
}
Run Code Online (Sandbox Code Playgroud)
所以,当我放断点时,流程如下:
没有超级电话:
在推动新VC的同时:
current viewWillDisappear //makes sense
new viewWillAppear //makes sense
current viewDidAppear // …Run Code Online (Sandbox Code Playgroud) 这可能是一个愚蠢的问题,但是在我的应用程序中,需要将bool变量传递给方法。
假设我有10个BOOL变量声明为b1,b2.....b10。
我可以BOOL简单地使用以下代码将值作为参数发送:
[self sendBoolValue:YES];
- (void)sendBoolValue:(BOOL)value
{
b1 = value;
// now b1 will be YES.
}
Run Code Online (Sandbox Code Playgroud)
现在,我需要执行以下操作:
[self sendBoolVariable:b1]; // I tried sending &b1, but it didnt work out.
- (void)sendBoolVariable:(BOOL)value
{
value = YES; // trying to set b1 to YES.
// b1 is still NO.
}
Run Code Online (Sandbox Code Playgroud)
我无法发送BOOL变量。这有可能吗?
为什么我要这样做?:
我有一个UIView在3x3的网格布局中有9个子视图(我称它们为图块)。
我有两个BOOL值startTile和endTile。我需要基于触摸设置这些值!
我正在touches-Began/Moved/Ended检测这些视图上的触摸
触摸开始时,我需要计算触摸是在tile1还是tile2中.....
所以实际的代码:
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
// …Run Code Online (Sandbox Code Playgroud) 我对 spritekit 坐标系很困惑。我需要澄清两个案例。
情况1:
当一个精灵节点作为子节点添加到场景中时:
SKSpriteNode * blueBall = [SKSpriteNode spriteNodeWithImageNamed:@"hRedBall.png"];
blueBall.name=@"blueball";
blueBall.size=CGSizeMake(75, 75);
blueBall.position=point; //I am varying this point
[self addChild:blueBall];
Run Code Online (Sandbox Code Playgroud)
我每次都在不同的点添加节点。这些是我在以下位置添加节点的点: (100x100)(200x200)(300x300)(400x400)(900,600)
在我的 iphone 5 设备中,它们看起来像这样:
如果您查看 100x100,当我在设备上的 (100,100) 点添加精灵时,当我记录节点位置时,它向我显示 (99.9,138.17),这与点 (100,100) 相比存在巨大差异。
即使其他点也有变化,我忽略了它们,因为对于其他点来说差异太小了。
-(void)didMoveToView:(SKView *)view {
/* Setup your scene here */
[self bounceTheBlueBallAtPoint:CGPointMake(100, 100)];
}
-(void)bounceTheBlueBallAtPoint:(CGPoint)point{
SKSpriteNode * blueBall = [SKSpriteNode spriteNodeWithImageNamed:@"hRedBall.png"];
blueBall.name=@"blueball";
blueBall.size=CGSizeMake(75, 75);
blueBall.physicsBody=[SKPhysicsBody bodyWithCircleOfRadius:blueBall.frame.size.width/2];
blueBall.physicsBody.categoryBitMask=blueBallHitCategory;
blueBall.physicsBody.collisionBitMask=blueBallHitCategory|pinkBallHitCategory|wallHitCategory;
blueBall.physicsBody.contactTestBitMask=blueBallHitCategory|pinkBallHitCategory|wallHitCategory;
blueBall.physicsBody.dynamic=YES;
blueBall.physicsBody.affectedByGravity=NO;
blueBall.physicsBody.restitution=1.0;
blueBall.physicsBody.friction=0.0;
blueBall.physicsBody.linearDamping=0.0;
blueBall.physicsBody.angularDamping=0.0;
blueBall.position=point;
[self addChild:blueBall];
//applying impulse to bounce off
// CGVector …Run Code Online (Sandbox Code Playgroud) 我想在代码中而不是在主情节提要中更改整个表视图大小(x,y,宽度,高度)。我在故事板中制作了没有布局的表格视图。我试过这个:
@IBOutlet weak var tableView: UITableView!
override func viewDidLoad() {
super.viewDidLoad()
tableView.frame.size.width = self.view.frame.size.width
tableView.frame.size.height = self.view.frame.size.height
tableView.reloadData()
}
Run Code Online (Sandbox Code Playgroud)
但这没有用
我正在尝试构建一个简单的 Hello world JavaCard 小程序。我正在使用 NetBeans IDE。
我正在关注本教程。
这是我的代码:
package classicapplet1;
import javacard.framework.*;
import java.rmi.Remote;
import javacard.framework.service.Dispatcher;
import javacard.framework.service.RMIService;
import javacard.framework.service.Service;
public class JavaCardApplet extends Applet {
HelloWorld hello;
Dispatcher disp;
Service svc;
public static void install(byte[] bArray, short bOffset, byte bLength) {
new JavaCardApplet();
}
private JavaCardApplet() {
// register();
hello = new HelloWorld();
svc=new RMIService((Remote) hello);
disp = new Dispatcher((short)1);
disp.addService(svc, Dispatcher.PROCESS_COMMAND);
}
public static void install(byte[] buf, short ofs, short len){
(new JavaCardApplet()).register();
}
public void …Run Code Online (Sandbox Code Playgroud) 我想更改警报操作按钮的顺序,根据代码,我尝试了所有可能性,但不允许我更改序列.
在这里查看我的代码
UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"alert" message:@"My alert message" preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction* noButton = [UIAlertAction
actionWithTitle:@"Cancel"
style:UIAlertActionStyleCancel
handler:^(UIAlertAction * action)
{
[alertController dismissViewControllerAnimated:YES completion:nil];
}];
UIAlertAction* yesButton = [UIAlertAction
actionWithTitle:@"OK"
style:UIAlertActionStyleDefault
handler:^(UIAlertAction * action)
{
[alertController dismissViewControllerAnimated:YES completion:nil];
}];
[alertController addAction:yesButton];
[alertController addAction:noButton];
[self presentViewController:alertController animated:YES completion:nil];
Run Code Online (Sandbox Code Playgroud)
这会给我以下结果.我想在右手边更改取消,button在左手边更改确定button.
我很感激你的时间.
ios ×6
objective-c ×3
swift ×2
boolean ×1
build.gradle ×1
cocoa ×1
ios-darkmode ×1
ios13 ×1
javacard ×1
macos ×1
netbeans-8 ×1
nstextfield ×1
nstextview ×1
skspritenode ×1
sprite-kit ×1
uitableview ×1
xcode11 ×1